in reply to Re^2: Reading a CSV file
in thread Reading a CSV file

alchang ,
If there was no output at all, then you likely have an empty file. That code should have done 1 of 2 things:
1. Generated an error because you were unable to open the file 2. Printed every line in the file
Since it did neither, I must assume that the file exists, you can open it, but that it is empty. Using a module will not change that. I recommended it because CSV can be tricky but you aren't yet at the tricky part.

Update: Since you have said elsewhere in the thread that the file is 63MB - consider that you may have two files with the same name in different directories. Since you have not told perl to open a file with an absolute path, it is looking for a file in the same directory that you executed perl from.

Cheers - L~R

Replies are listed 'Best First'.
Re^4: Reading a CSV file
by alchang (Novice) on Mar 31, 2008 at 14:49 UTC
    I think i gave Perl a path to find the file but there is still no output. To be sure I did the right thing here's what I changed:
    open(my $fh, '<', 'C:\bio stuff\Aubrey\'s project\dev.csv') or die "Un +able to open 'dev.csv' for read
    Is that what you meant?
      alchang,
      Yes, that is an absolute path. I apologize if the following sounds a bit hand-holdy, but it is difficult to troubleshoot without seeing what you see:
      C:\>cd "bio stuff\Aubrey's project" C:\bio stuff\Aubrey's project>more dev.csv hit q once you are satisfied that the file is not empty C:\bio stuff\Aubrey's project>notepad testit.pl Copy and paste my code exactly into testit.pl - without absolute path C:\bio stuff\Aubrey's project>perl testit.pl
      If that produces no output and all the steps leading up to it appear to be successful, I give up.

      Cheers - L~R

        Hmm, when I use the more command nothing comes out at all and pressing q doesn't quit, I have to use ctrl-c. When I use notepad to view dev.csv it definitely has lines of data though.

      The backslash is an escape character! If you want to use a windows-style path, you need to escape the backslashes:

      open(my $fh, '<', 'C:\\bio stuff\\Aubrey\'s project\\dev.csv')
      <radiant.matrix>
      Ramblings and references
      The Code that can be seen is not the true Code
      I haven't found a problem yet that can't be solved by a well-placed trebuchet