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

Thanks for your response. I copied and pasted your code but there still was no output. I'll try to obtain Text::CSV and see if that works.

Replies are listed 'Best First'.
Re^3: Reading a CSV file
by Limbic~Region (Chancellor) on Mar 31, 2008 at 14:39 UTC
    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

      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

        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