I have a .data file which is essentially just a text file with a bunch of numbers.
It's in the format "xx yy zzz abc
ccf fffd sss xxx
xx sss qq"
Basically it is a random amount of numbers per line separated using spaces (not tabs or commas).
What I need to do is parse the file to a format which would be more suitable to use for a SQl database system I am implementing. I need the output file to look like
"1,xx
1,yy
1,zzz
1,abc
2,ccf
2,fffd
2,sss" ... and so on
I have no clue how to use Perl but have been recommended to do so for parsing text files. The code should be about 10-20 lines from my understanding and it would be great if someone could help me out. I tried searching for something but could barely decipher what was out there.
Till now all I have is
Expand|Select|Wrap|Line Numbers
- #!/usr/local/bin/perl
- #program to modify data
- $file = 'users/Damien/Downloads/DOROTHEA/dorothea_test.data;
- open(INFO, $file);
- open(DATA, ">edited");
- @lines = <INFO>;
- @count = 1;
- foreach $line (@lines)
- {