Block2csv: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<pre>
<pre>
#!/usr/bin/perl -w
#!/usr/bin/perl -w
# you data is in "paragraphs"
# The record delimiter is two carriage returns, and the field delimiter is a carriage return.
# you get this form html tables for html div monsters
# feed the text into this and it will convert record separator to simply carriage return, and field delimiter to comma.


use strict;
use strict;
Line 17: Line 22:
</pre>
</pre>


also see: [[furl.awk]] when there is no record separator, but you have a fixed number of fields per record.


[[Category:script]]
[[Category:Script]]

Latest revision as of 20:19, 16 July 2021

#!/usr/bin/perl -w

# you data is in "paragraphs"
# The record delimiter is two carriage returns, and the field delimiter is a carriage return.
# you get this form html tables for html div monsters
# feed the text into this and it will convert record separator to simply carriage return, and field delimiter to comma.

use strict;
use Data::Dumper;

$/ = "\n\n";

# Datastore
while (<>){
    # print;
    my $r;
    my @arr =  split "\n";
    print join ( "," , @arr ) . "\n";
}

also see: furl.awk when there is no record separator, but you have a fixed number of fields per record.