Hello monks,
I am trying to convert a txt file to csv which isn't really too difficult, however I'm not too sure how I would go about it with a text file that isn't pre formatted to having all of a clients info on one line, second client on second line, etc. This is how the txt file currently reads:
Jacobs, April 750.467.9582 quam.quis@sedhendrerit.org Mays, Martena 870.348.1974 sollicitudin@nonummyFusce.org McNeil, Brennan 289.527.6151 lobortis@nisl.com Sexton, Melvin 599.927.5337 in.felis@varius.com Blackburn, Prescott 661.589.1228 sed@egetlaoreetposuere.edu
I need to basically format the info in a csv file to read as a table with headers of Name, Phone and email. Each different client on a new row.
This is what I currently have as far as reading in the text file and writing the csv file. My problem is I have no idea how I would go about grabbing data into specific fields with the way the txt file is currently formatted.
use strict; use warnings; my $infile="clients.txt"; open my $in, "<", $infile or die $!; open my $out, ">" , "clients.csv" or die $!; my $client = <$in>; chomp($client);
Any help greatly appreciated.
In reply to converting txt to csv and formatting by csorrentini
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |