<?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: export a each row from a CSV, with 100s of rows, as an individual text file in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124163#M782</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The short answer is: yes. Use the &lt;A href="https://docs.python.org/2/library/csv.html"&gt;CSV module&lt;/A&gt;: read a line from the CSV and write the line to a text file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Aug 2014 20:33:25 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2014-08-25T20:33:25Z</dc:date>
    <item>
      <title>export a each row from a CSV, with 100s of rows, as an individual text file</title>
      <link>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124162#M781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to have python export a single row from a CSV, with 100s of rows, as an individual text file? IE if you had a CSV with 100 rows you would get 100 .txt files for each row/record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advanced!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Aug 2014 20:20:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124162#M781</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2014-08-25T20:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: export a each row from a CSV, with 100s of rows, as an individual text file</title>
      <link>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124163#M782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The short answer is: yes. Use the &lt;A href="https://docs.python.org/2/library/csv.html"&gt;CSV module&lt;/A&gt;: read a line from the CSV and write the line to a text file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Aug 2014 20:33:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124163#M782</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2014-08-25T20:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: export a each row from a CSV, with 100s of rows, as an individual text file</title>
      <link>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124164#M783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alternative option is to use the Pandas library to read in the .csv, go thru the unique rows and export each one to it's own .csv file.&amp;nbsp; In this example it just names each of the unique .csv files using the first column specified ('fc')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import pandas as pd&lt;BR /&gt;import numpy as np&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import pandas as pd





def exportCSVbyRow(csvfile):
&amp;nbsp;&amp;nbsp;&amp;nbsp; src = csvfile
&amp;nbsp;&amp;nbsp;&amp;nbsp; tab = pd.io.parsers.read_table(str(src), sep=',')
&amp;nbsp;&amp;nbsp;&amp;nbsp; uniquerows = np.unique(tab['fc'])
&amp;nbsp;&amp;nbsp;&amp;nbsp; for key in uniquerows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print key
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exprow = tab[tab['fc'] == key]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exprow.to_csv(r'H:\Documents\\' + str(key) + '.csv')





exportCSVbyRow(r'H:\Documents\arlist.csv')


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:07:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124164#M783</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T07:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: export a each row from a CSV, with 100s of rows, as an individual text file</title>
      <link>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124165#M784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all for the help, really appreciate it! I was asking for a colleague and it looks like she figured it out. Ill post her script when she sends it. Great community we got here!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;M &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2014 20:58:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/export-a-each-row-from-a-csv-with-100s-of-rows-as/m-p/124165#M784</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2014-08-26T20:58:20Z</dc:date>
    </item>
  </channel>
</rss>

