Re: How to read files with commas as separators?
- From: David Thompson <dave.thompson2@xxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 04:27:46 GMT
<mostly offtopic>
On Tue, 18 Mar 2008 22:32:35 -0800, glen herrmannsfeldt
<gah@xxxxxxxxxxxxxxxx> wrote:
zuying@xxxxxxxxx wrote:
Don't need the unquoted comma; that generates a field separator (whichBut the data file is of 5Gb in size so it's hard to add another comma
there in every occasion.
awk will do it with
awk '{print $0,","}' oldfile > newfile
(the quote conventions on windows make it harder to do inline)
defaults to space, harmless here) before the comma. String
concatentation in awk is done with the null operator:
sh$ awk '{print $0 ","}'
You can avoid awk "string" literals for some cases including this one
in Windows command processor by using a variable:
CMD> awk -vco=, "{print $0 co}"
However, sed is usually available where awk is, and has no issue:
sed s/$/,/ oldfile >newfile
(Even in Unixy shells where $name is special, $/ isn't.)
Also pre-patching doubles the disc space and triples the time to
read,write,read all the data, if those are problems. Unless the
Fortran can be changed to read from stdin (typically 5, as we just
discussed) and you pipe the results into it, then you only have the
cost of pipe buffering which is reasonably small. But if you can
change the Fortran, the internal-read already discussed works.
- formerly david.thompson1 || achar(64) || worldnet.att.net
.
- References:
- How to read files with commas as separators?
- From: zuying@xxxxxxxxx
- Re: How to read files with commas as separators?
- From: Arjen Markus
- Re: How to read files with commas as separators?
- From: glen herrmannsfeldt
- Re: How to read files with commas as separators?
- From: zuying@xxxxxxxxx
- Re: How to read files with commas as separators?
- From: glen herrmannsfeldt
- How to read files with commas as separators?
- Prev by Date: Re: Rounding off double precision
- Next by Date: Re: data with metadata
- Previous by thread: Re: How to read files with commas as separators?
- Next by thread: Re: How to read files with commas as separators?
- Index(es):
Relevant Pages
|
|