Block2csv

From Federal Burro of Information
Revision as of 20:19, 16 July 2021 by David (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
#!/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.