Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Perl script help to convert .txt file to .csv

by littlemonk (Sexton)
on Jan 06, 2014 at 13:48 UTC ( #1069513=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Perl script help to convert .txt file to .csv
in thread Perl script help to convert .txt file to .csv

try this code ..

use strict; use warnings; open ( my $in ,"intxt.txt") || die "check the input file...not able t +o open $!"; open ( my $out ,">output.txt") || die "check the input file...not abl +e to open $!"; $/=""; my $in_whole= <$in>; $in_whole=~ s/\n//g; my @arr=split(">",$in_whole); my $fout=join(">",@arr); print $fout; $fout=~ s/>/\n>/g; $fout=~ s/^(\n)//; $fout=~ s/\s/,/g; $fout=~ s/length=//g; @arr=split(">",$fout); $fout=join(">",@arr); $fout=~ s/>/\n>/g; $fout=~ s/^(\n)//; $fout=~ s/,\n/\n/g; print $out $fout; close($in); close($out);


Comment on Re^3: Perl script help to convert .txt file to .csv
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069513]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2014-07-25 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (170 votes), past polls