<?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: Comma Separated Files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012825#M128965</link>
    <description>Hi,&lt;BR /&gt;Try a very simple solution,&lt;BR /&gt;cat &lt;FILE&gt; |ts -s "," &amp;gt;newfile&lt;BR /&gt;&lt;BR /&gt;This removes repeating , and the fields with data is extracred.&lt;/FILE&gt;</description>
    <pubDate>Wed, 02 Jul 2003 06:25:18 GMT</pubDate>
    <dc:creator>Leif Halvarsson_2</dc:creator>
    <dc:date>2003-07-02T06:25:18Z</dc:date>
    <item>
      <title>Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012815#M128955</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a comma separated file containing irrelevant data which is separated by commas, does anyone know of a way I can extract only the fields/columns which have data and ignore the blank/comma separated values?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 02 Jul 2003 04:04:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012815#M128955</guid>
      <dc:creator>Edgar_10</dc:creator>
      <dc:date>2003-07-02T04:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012816#M128956</link>
      <description>I think you will need to give slightly more detail in terms of what you are trying to accomplish.  You will be importing this information into what?  A spreadsheet? A database? Are you sure you want to get rid of the fields that have blank data?  You can use&lt;BR /&gt;vi to edit the file and the following will eliminate the blank/comma separated values:&lt;BR /&gt;&lt;BR /&gt;:s/ ,//g&lt;BR /&gt;&lt;BR /&gt;The above searches for a blank space followed by a comma and deletes both and replaces them globally in the file.  But you do need to provide more information for someone to be able to help you.</description>
      <pubDate>Wed, 02 Jul 2003 04:15:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012816#M128956</guid>
      <dc:creator>William Wong_2</dc:creator>
      <dc:date>2003-07-02T04:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012817#M128957</link>
      <description>Hi William,&lt;BR /&gt;&lt;BR /&gt;I need to extract only the field which contain data as that is the data I will use with oracle sql loader to load into a table. Basically I have a comma separated files which contain approx.6000 records. Each record has about 100 fields but only 20 are populated with data, the rest is comma separated blanks.&lt;BR /&gt;&lt;BR /&gt;What I want to do is extract only the 20 populated fields.&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Wed, 02 Jul 2003 04:33:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012817#M128957</guid>
      <dc:creator>Edgar_10</dc:creator>
      <dc:date>2003-07-02T04:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012818#M128958</link>
      <description>Hi William,&lt;BR /&gt;&lt;BR /&gt;I need to extract only the field which contain data as that is the data I will use with oracle sql loader to load into a table. Basically I have a comma separated files which contain approx.6000 records. Each record has about 100 fields but only 20 are populated with data, the rest is comma separated blanks.&lt;BR /&gt;&lt;BR /&gt;What I want to do is extract only the 20 populated fields.&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Wed, 02 Jul 2003 04:37:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012818#M128958</guid>
      <dc:creator>Edgar_10</dc:creator>
      <dc:date>2003-07-02T04:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012819#M128959</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;A cut might probably help you, see the example below:&lt;BR /&gt;&lt;BR /&gt;# echo "a,,c,,e" | cut -d , -f 1,3,5&lt;BR /&gt;a,c,e&lt;BR /&gt;&lt;BR /&gt;You should know which field(s) in the record contains data and I believe that the sequence of fields that contain data are same for each record, so to convert the file to extract only fields with data, you can:&lt;BR /&gt;&lt;BR /&gt;# cat input.csv | cut -d , -f 2,3,4,8,9 &amp;gt; output.csv&lt;BR /&gt;&lt;BR /&gt;you can get the new csv file with only the fields you want.&lt;BR /&gt;&lt;BR /&gt;Kenneth</description>
      <pubDate>Wed, 02 Jul 2003 05:02:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012819#M128959</guid>
      <dc:creator>Kenneth_19</dc:creator>
      <dc:date>2003-07-02T05:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012820#M128960</link>
      <description>Hi,&lt;BR /&gt;my idea is the following: we translate each comma in a space, and after all you your input is separated by space.&lt;BR /&gt;&lt;BR /&gt;After you can get all the data with a cycle..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;example:&lt;BR /&gt;&lt;BR /&gt;ciccio.txt contains&lt;BR /&gt;&lt;BR /&gt;1,2,3,,,,5,6,7,,9&lt;BR /&gt;,,3,4,6,,8,,,2,,4,5,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then we do:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat ciccio.txt | tr "," " " | while read ....&lt;BR /&gt;do&lt;BR /&gt;&lt;YOUR commands="" here=""&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;the series of dots should be at least equal to the max number of argument expected.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt; Massimo&lt;BR /&gt;&lt;/YOUR&gt;</description>
      <pubDate>Wed, 02 Jul 2003 05:30:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012820#M128960</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-07-02T05:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012821#M128961</link>
      <description>Hi Ken,&lt;BR /&gt;&lt;BR /&gt;I had already attempted to use "cut" but this is only for fixed format records and unfortunately not all the records contain identical populated columns/fields.&lt;BR /&gt;&lt;BR /&gt;Do you/anyone know of a perl/sed/awk script that could read through a file, and pick out specific fields/columns?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!</description>
      <pubDate>Wed, 02 Jul 2003 05:36:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012821#M128961</guid>
      <dc:creator>Edgar_10</dc:creator>
      <dc:date>2003-07-02T05:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012822#M128962</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Something like that ???&lt;BR /&gt;&lt;BR /&gt;# cat c.txt&lt;BR /&gt; , , , , 2 ,  ,2 ,3,3, , , ,&lt;BR /&gt;3, , , ,3,4, , ,4,5 , ,5 ,5 , &lt;BR /&gt;,45,5,345,5,4,6,6,  , , ,5 , ,&lt;BR /&gt;&lt;BR /&gt;# sed 's/,/ /g' c.txt | sed 's/  */,/g' | sed -e 's/^,//' -e 's/,$//'&lt;BR /&gt;&lt;BR /&gt;2,2,3,3&lt;BR /&gt;3,3,4,4,5,5,5&lt;BR /&gt;45,5,345,5,4,6,6,5&lt;BR /&gt;&lt;BR /&gt;first sed replaces , with space&lt;BR /&gt;second sed replaces all spaces with one ,&lt;BR /&gt;third sed eliminates , from beginnig and end of line&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Jul 2003 05:48:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012822#M128962</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2003-07-02T05:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012823#M128963</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;In that case, if the number and positions of each record are not the same, how can you import them back to the database with sqlldr?&lt;BR /&gt;You might have hundreds of combinations then!!!&lt;BR /&gt;&lt;BR /&gt;Get one step back, why you want to eliminate the empty fields if they are finally loaded into the same table, where the fields will still be empty even you don't load anything for it?&lt;BR /&gt;&lt;BR /&gt;If you really want to make this done, try:&lt;BR /&gt;&lt;BR /&gt;# sed "1,$ s/,,/,/g" input.csv &amp;gt; output.csv&lt;BR /&gt;&lt;BR /&gt;if the csv files have character fields that are also wrapped with double quote, run again:&lt;BR /&gt;&lt;BR /&gt;# sed "1,$ s/,"",//g" output.csv &amp;gt; output2.csv&lt;BR /&gt;&lt;BR /&gt;This can eliminate empty fields, but you might need some extra effort to get rid of the extra "," at the very beginning and towards the end of each record if the first and the last field is empty.&lt;BR /&gt;&lt;BR /&gt;Kenneth</description>
      <pubDate>Wed, 02 Jul 2003 05:56:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012823#M128963</guid>
      <dc:creator>Kenneth_19</dc:creator>
      <dc:date>2003-07-02T05:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012824#M128964</link>
      <description>Hi,&lt;BR /&gt;if you know the number of arguments, you can:&lt;BR /&gt;-  use my previous answer&lt;BR /&gt;- put as many variable as you nedd in the while loop&lt;BR /&gt;- print only those field that are not empty !&lt;BR /&gt;&lt;BR /&gt;  Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Jul 2003 06:00:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012824#M128964</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-07-02T06:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012825#M128965</link>
      <description>Hi,&lt;BR /&gt;Try a very simple solution,&lt;BR /&gt;cat &lt;FILE&gt; |ts -s "," &amp;gt;newfile&lt;BR /&gt;&lt;BR /&gt;This removes repeating , and the fields with data is extracred.&lt;/FILE&gt;</description>
      <pubDate>Wed, 02 Jul 2003 06:25:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012825#M128965</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2003-07-02T06:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012826#M128966</link>
      <description>Sorry,&lt;BR /&gt;It should of course be "tr" not "ts".</description>
      <pubDate>Wed, 02 Jul 2003 06:26:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012826#M128966</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2003-07-02T06:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012827#M128967</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Thanks for the invaluable feedback! As mentioned I have csv files containing approx.16000 rows/records which are 100 fileds/columns in length.&lt;BR /&gt;&lt;BR /&gt;My aim is to extract only fields 3,7,12,22,33,46.&lt;BR /&gt;&lt;BR /&gt;Is this possible?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!</description>
      <pubDate>Wed, 02 Jul 2003 06:44:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012827#M128967</guid>
      <dc:creator>Edgar_10</dc:creator>
      <dc:date>2003-07-02T06:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012828#M128968</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;Then my previous answer is the solution!&lt;BR /&gt;&lt;BR /&gt;# cat input.csv | cut -d , -f 3,7,12,22,33,46 &amp;gt; output.csv &lt;BR /&gt;&lt;BR /&gt;Let me explain the syntax:&lt;BR /&gt;&lt;BR /&gt;for the cut command, -d is for specifying delimiter therefore "-d ," is for comma seperated fields, -f is for specifying the field number based on the delimiter given, "so -f 3,7,12,22,33,46" is to extract the 3rd, 7th, 12th, 22th, 33th, and 46th field from each record.&lt;BR /&gt;&lt;BR /&gt;Kenneth</description>
      <pubDate>Wed, 02 Jul 2003 07:29:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012828#M128968</guid>
      <dc:creator>Kenneth_19</dc:creator>
      <dc:date>2003-07-02T07:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Comma Separated Files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012829#M128969</link>
      <description>Hi,&lt;BR /&gt;awk solution:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk -F, '( print $3,$7,$12,$22,$33,$46 )' FILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;the purpose of the "," in the print to put a space between the fieds...&lt;BR /&gt;&lt;BR /&gt;  Massimo&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Jul 2003 07:40:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/comma-separated-files/m-p/3012829#M128969</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-07-02T07:40:09Z</dc:date>
    </item>
  </channel>
</rss>

