<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to read CSV file if some of values are in wrapped text when its created. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229333#M41503</link>
    <description>&lt;P&gt;Search this site as we have answered this question many times.&lt;/P&gt;
&lt;P&gt;1) If the file was generated on a PC and you are lucky then the actual end of records indicators will be CR+LF and the embedded line breaks will just be CR or LF. &amp;nbsp;If that is true then you can try reading the file using the INFILE option TERMSTR=CRLF. &amp;nbsp;If you move the file from a PC to Unix to process with SAS then make sure to move it as BINARY and not TEXT so that the end of line characters are not modified.&lt;/P&gt;
&lt;P&gt;2) If the file is consistent in the use of double quotes to protect values with embedded line breaks then you can create a fixed version by reading the file character by character and replacing the embedded LF or CR with some other character.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Oct 2015 16:54:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2015-10-09T16:54:21Z</dc:date>
    <item>
      <title>how to read CSV file if some of values are in wrapped text when its created.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229276#M41481</link>
      <description>&lt;P&gt;Hello SAS users,&lt;/P&gt;
&lt;P&gt;I have a csv file on Linux box. I am trying to read this file using SAS EG. But some of the value are wrapped text (I found it when I moved this file to windows and opened in Excel, The data values I have issues are wrapped text). I am not able to read this csv file into sas dataset without out errors.&lt;/P&gt;
&lt;P&gt;sample of csv file as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;101,"Laptop","This device is in good condition, store it&amp;nbsp; in the shelf"&lt;/P&gt;
&lt;P&gt;102,"Monitors","we have 100 monitors, about 80 are in good condition.&lt;/P&gt;
&lt;P&gt;and 20 need to be fixed"&lt;/P&gt;
&lt;P&gt;103,"Mice","we have 250 mice most of them in good conditon."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using following code to read above csv file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;data inven,&lt;/P&gt;
&lt;P&gt;infile "infile_path" delimiter=',' DSD lrecl=32000 termstr=LF ;&lt;/P&gt;
&lt;P&gt;attrib item_no length=8 format=11.&lt;/P&gt;
&lt;P&gt;input item_id @;&lt;/P&gt;
&lt;P&gt;attrib Item_name length=$8. format=$8.&lt;/P&gt;
&lt;P&gt;input Item_name $ @;&lt;/P&gt;
&lt;P&gt;attrib comment length=$80. format=$80.&lt;/P&gt;
&lt;P&gt;input comment $ @;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in second row comments variable value is wrapped text ,it has multiple end of line.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;how to read this kind of CSV files?&lt;/STRONG&gt; Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 13:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229276#M41481</guid>
      <dc:creator>nbonda</dc:creator>
      <dc:date>2015-10-09T13:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to read CSV file if some of values are in wrapped text when its created.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229296#M41487</link>
      <description>&lt;P&gt;Issue is that you have either LF or CR/LF in the actual data. How big is the file and will you need to process this type of data again?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're going to be doing this a lot it may well be worthwhile going further back in the data stream and removing the LF or CR/LF from the data before extracting to the csv.&lt;/P&gt;
&lt;P&gt;I recommend beating the data entry people with wet spaghetti noodles as well.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 14:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229296#M41487</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-09T14:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to read CSV file if some of values are in wrapped text when its created.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229299#M41489</link>
      <description>&lt;P&gt;I agree with ballardw. &amp;nbsp;Go back to the source and get them to fix it. &amp;nbsp;I had it with a certain database sending CSV data, they changed a flag their end and fixed the problem.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 14:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229299#M41489</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-10-09T14:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to read CSV file if some of values are in wrapped text when its created.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229333#M41503</link>
      <description>&lt;P&gt;Search this site as we have answered this question many times.&lt;/P&gt;
&lt;P&gt;1) If the file was generated on a PC and you are lucky then the actual end of records indicators will be CR+LF and the embedded line breaks will just be CR or LF. &amp;nbsp;If that is true then you can try reading the file using the INFILE option TERMSTR=CRLF. &amp;nbsp;If you move the file from a PC to Unix to process with SAS then make sure to move it as BINARY and not TEXT so that the end of line characters are not modified.&lt;/P&gt;
&lt;P&gt;2) If the file is consistent in the use of double quotes to protect values with embedded line breaks then you can create a fixed version by reading the file character by character and replacing the embedded LF or CR with some other character.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 16:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229333#M41503</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-10-09T16:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to read CSV file if some of values are in wrapped text when its created.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229334#M41504</link>
      <description>&lt;P&gt;Thank you for you suggesion. It's very big file,&amp;nbsp; has few millions of rows, we get these files everyday. we are bugging data management to change it :), they are asking us to read some&amp;nbsp;for now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 17:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-CSV-file-if-some-of-values-are-in-wrapped-text-when/m-p/229334#M41504</guid>
      <dc:creator>nbonda</dc:creator>
      <dc:date>2015-10-09T17:09:52Z</dc:date>
    </item>
  </channel>
</rss>

