in reply to Re: Exporting from flatfile database
in thread Exporting from flatfile database
would corrupt the data with:open IN, "infile.dat"; open OUT, ">data.csv"; while (<IN>) { chomp $_; my @fields = split(/|/, $_); my $newLine = join(",", @fields); print OUT "$newLine\n" } close IN; close OUT;
Using pipes to delimit data is a better idea (usually) because it is less common in data. There are also several modules to parse CSV. Incuding Text::CSV. UPDATE: tilly has pointed out that Text::CSV_XS is a better solution than Text::CSV. I handles imbedded line endings in the data. grephi|I'm with GNU,Inc.|I need a comma in my title this|will|produce|,|to|many|fields
grep> cd pub grep> more beer
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Exporting .csv file to EXCEL
by naive (Novice) on Jan 23, 2002 at 12:50 UTC |