yes I’m working with MS…
Thanks very much
Il giorno martedì 28 agosto 2012 12:12:33 UTC+2, Ryan Ren ha scritto:
awk should work. you can try it in shell to see what happens.
To get the text after the dot:
in Linux bash shell,
$ awk -F’.’ '{print 2}' example.txt
in MS cmd shell,
awk -F"." “{print $2}” example.txt
since your previsous try failed, I guess you are using GAMS under MS Windows.
In this case, 2 lines below will do you work:
$call awk -F"." “{print $2}” example.txt > “%gams.scrdir%example.dat”
$include “%gams.scrdir%example.dat”
HTH,
Yan
2012-08-28
Robi07, 2012-08-28 16:23:07
Subject:Re: Read A PIECE of a *.txt file
I need to read this file because I have to automate the process of data
acqusition…
I’ve tried with awk but I get error (Error 460: Empty data statements not
allowed)
So I’ve thought to use the command:
$call cut $call cut -d. -f1 example.txt > “%gams.scrdir%example.dat”
$include “%gams.scrdir%example.dat”
and it works
but if I try to get characters after the dot I get error
$call cut $call cut -d. -f2 example.txt > “%gams.scrdir%example.dat”
$include “%gams.scrdir%example.dat”
(Error 172 element is redifined).
So I’ve thought to reverse the input data and then read new data before the
dot but how could I do this?
Thanks
Roby
Il giorno martedì 28 agosto 2012 04:24:30 UTC+2, Ryan Ren ha scritto:
why do your need to read such a file?
If you know in advance the set that contains the keys before and after the
dots,
this wouldI be simply as:
*----
set a /ABC222,GHI444,OPQ666,UVW888/;
set b /DEF333,LMN555,RST777,XYZ999/;
set c(a,b)
/
$include a.txt
/
;
*----
Then your txt file is used to init set c.
otherwise I think you can use awk to process your text file to get what
you want.
awk -F’.’ ‘{print $1}’ example.txt
HTH,
Yan
2012-08-28
Robi07, 2012-08-27 15:05:42
Subject:Read A PIECE of a *.txt file
Hi,
I need your help for the problem that I’m facing:
I want to read JUST the first part of a *.txt file and store it in a set
(to create a table).
(I’ve tried with $include but it reads all the data and this is not what I
want).
I’ve attached an example of the *.txt file that I use: in this case I need
to read just the characters/numbers before the dot (i.e ABC222; GHI444;
OPQ666,UVW888) .
Thanks
Roby
–
To view this discussion on the web visit https://groups.google.com/d/msg/gamsworld/-/mbTFH7P15wYJ.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.