<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:courier,monaco,monospace,sans-serif;font-size:10pt"><div style="font-family: courier,monaco,monospace,sans-serif; font-size: 10pt;"><span style="font-style: italic;"></span>check this:<br><span><a target="_blank" href="http://en.wikipedia.org/wiki/Newline">http://en.wikipedia.org/wiki/Newline</a></span><br>How did you get .cvs? How did you rename it to .txt?<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Eric Ellington <e.ellington@gmail.com><br>To: Chicago.pm chatter <chicago-talk@pm.org><br>Sent: Saturday, December 15, 2007 11:47:20 AM<br>Subject: Re: [Chicago-talk] Why does Perl hate my csv file?<br><br>
I don't follow. I thought $/ was newline by default and I thought<br>newline was a carriage return. Am I wrong? Why does my problem go away<br>if I name all my files with a .txt extension?<br><br>On Dec 13, 2007 10:32 PM, tiger peng <<a ymailto="mailto:tigerpeng2001@yahoo.com" href="mailto:tigerpeng2001@yahoo.com">tigerpeng2001@yahoo.com</a>> wrote:<br>><br>> it seems that all line end with carriage return character (ascii
octal num<br>> 15) only. There is no line feed (newline character in Unix)<br>><br>> I made one in Linux and you can see the difference:<br>><br>> gpeng@linbay:/home/gpeng/perl<br>> -> perl -ne 'print $_' 2.csv<br>><br>> WLANE_02,51,3.2,55,60,32,19,0,0,17.6,17.1,11/1/2007,0:00:00,,<br>> gpeng@linbay:/home/gpeng/perl<br>> -> perl -ne 'print $_,"\n"' 2.csv<br>><br>> WLANE_02,51,3.2,55,60,32,19,0,0,17.6,17.1,11/1/2007,0:00:00,,<br>><br>> gpeng@linbay:/home/gpeng/perl<br>> -> perl -015 -ne 'print $_,"\n"' 2.csv # use carriage character as<br>> recorder separator<br>><br>> Header<br>> RLANE_02,16,0.6,54,58,16,0,0,0,56.3,55.9,11/1/2007,0:00:00,,<br>> RLANE_01,8,0.3,56,59,8,0,0,0,112.5,112.2,11/1/2007,0:00:00,,<br>> ELANE_02,60,3.9,56,61,32,28,0,0,15,14.4,11/1/2007,0:00:00,,<br>> ELANE_01,23,1.3,60,65,13,10,0,0,39.1,38.6,11/1/2007,0:00:00,,<br>>
WLANE_01,10,0.3,57,58,9,1,0,0,90,89.7,11/1/2007,0:00:00,,<br>> WLANE_02,51,3.2,55,60,32,19,0,0,17.6,17.1,11/1/2007,0:00:00,,<br>><br>><br>> gpeng@linbay:/home/gpeng/perl<br>><br>><br>><br>><br>><br>> ----- Original Message ----<br>> From: Eric Ellington <<a ymailto="mailto:e.ellington@gmail.com" href="mailto:e.ellington@gmail.com">e.ellington@gmail.com</a>><br>> To: <a target="_blank" href="http://Chicago.pm">Chicago.pm</a> chatter <<a ymailto="mailto:chicago-talk@pm.org" href="mailto:chicago-talk@pm.org">chicago-talk@pm.org</a>><br>> Sent: Thursday, December 13, 2007 10:07:50 PM<br>> Subject: Re: [Chicago-talk] Why does Perl hate my csv file?<br>><br>> I am creating everything on a windows system. I checked the line<br>> endings and they look OK to me. Like I said the file works with any<br>> other extension besides csv. Giving it .123 worked.<br>><br>> The output is jacked
up in the windows cmd terminal, all of the
output<br>> is printed on the same line. I can watch it overwrite it self and
then<br>> I just get some data smashed<br>> onto one line.<br>><br>> Cut and Pasted:<br>> ,,,,,,,,,,,,1,42,44,2,0,0,0,450,449.7,12/1/2007,3:00:0000<br>><br>> This is a scaled down version of something larger. However, I am<br>> having the exact same problem with the code I posted and I am just<br>> testing with a different file which I attached to this email. If
there<br>> are any weird characters I am not sure what they are or how they are<br>> messing things up. I see nothing but CR's on every line and one LF on<br>> the final line.<br>><br>> I also turned on use warnings but got no warnings.<br>><br>> On Dec 13, 2007 6:49 PM, Andy Lester <<a ymailto="mailto:andy@petdance.com" href="mailto:andy@petdance.com">andy@petdance.com</a>> wrote:<br>> ><br>> > On Dec 13, 2007, at 6:46 PM, Eric Ellington wrote:<br>> ><br>> > > Change the file name to 1.txt and I get output or if I comment
out "my<br>> > > $x = <FILE>;" and even then the output is jacked up. Why is that?
Does<br>> > > open do something special when it sees a file that ends in .csv?
I<br>> > > found nothing at <a href="http://perldoc.perl.org/functions/open.html" target="_blank">http://perldoc.perl.org/functions/open.html</a> or
on<br>> > > ActiveState's website.<br>> ><br>> ><br>> > No, Perl doesn't care at all. There's something else going on that<br>> > you're not describing. Are the line-endings different for your<br>> > machine from the machine that you got the file from? You're on
Unix<br>> > and it came from Windows, or vice versa?<br>> ><br>> > Also, although "use strict" is a good thing, even more important is<br>> > "use warnings".<br>> ><br>> > Throw that in and see what else happens. And what does "the output
is<br>><br>> > jacked up" mean, anyway?<br>> ><br>> > xoox,<br>> > Andy<br>> ><br>> > --<br>> > Andy Lester => <a ymailto="mailto:andy@petdance.com" href="mailto:andy@petdance.com">andy@petdance.com</a> => <a target="_blank" href="http://www.petdance.com">www.petdance.com</a> =>
AIM:petdance<br>> ><br>> ><br>> ><br>> ><br>> > _______________________________________________<br>> > Chicago-talk mailing list<br>> > <a ymailto="mailto:Chicago-talk@pm.org" href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>> > <a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br>> ><br>><br>><br>><br>> --<br>><br>> Eric Ellington<br>> <a ymailto="mailto:e.ellington@gmail.com" href="mailto:e.ellington@gmail.com">e.ellington@gmail.com</a><br>><br>><br>> _______________________________________________<br>> Chicago-talk mailing list<br>> <a ymailto="mailto:Chicago-talk@pm.org" href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>> <a href="http://mail.pm.org/mailman/listinfo/chicago-talk"
target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br>><br><br><br><br>-- <br>Eric Ellington<br><a ymailto="mailto:e.ellington@gmail.com" href="mailto:e.ellington@gmail.com">e.ellington@gmail.com</a><br>_______________________________________________<br>Chicago-talk mailing list<br><a ymailto="mailto:Chicago-talk@pm.org" href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br></div><br></div></div></body></html>