Skip to content

Instantly share code, notes, and snippets.

@wogsland
Created January 21, 2013 01:28
Show Gist options
  • Save wogsland/4582983 to your computer and use it in GitHub Desktop.
Save wogsland/4582983 to your computer and use it in GitHub Desktop.
Have a ginormous CSV file with a bad line in it? Use this rather than some stupid program like excel which will take 5 minutes to open the file and then only gives you access to a small portion of it.
#!/usr/bin/perl
open (FOO, "file_with_bad_line.csv") ||
die "ERROR Unable to open test: $!\n";
open (BAR, ">badlines.csv");
$rowcount=0;
while (<FOO>) {
$rowcount++;
if ($rowcount == 1448571){
print BAR $_,"\n";
}
}
close FOO;
close BAR;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment