<?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: Extra rows when a .csv file is opened in Excel. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99785#M7742</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi James, that is definitely an answer.&amp;nbsp; I do thank for the code you posted, I will give it a try as I continue in with Python.&amp;nbsp; Right now I am just happy it is working, once I get more knowledgeable of the code I will go from I can see what it is doing to knowing what it is doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you again.&amp;nbsp; Dale,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jun 2014 15:59:45 GMT</pubDate>
    <dc:creator>DaleShearer</dc:creator>
    <dc:date>2014-06-05T15:59:45Z</dc:date>
    <item>
      <title>Extra rows when a .csv file is opened in Excel.</title>
      <link>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99781#M7738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I am on my 4th day of using Python and making a lot of progress.&amp;nbsp; I am looping through a feature class and writing field data to a .csv file.&amp;nbsp; It all runs good.&amp;nbsp; The issue is when I open the .csv file in Excel there is an empty row between each row of data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When writing a .csv file from VB.net there are no empty rows when the file is opened in Excel.&amp;nbsp; On the file created with Python all the data is there, just all spaced out with an empty row between.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do not have a spacing character (if there is one) in the .writerow statement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I fix this so there are no empty rows when I open the .csv file in Excel?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your time.&amp;nbsp; Dale,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 14:50:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99781#M7738</guid>
      <dc:creator>DaleShearer</dc:creator>
      <dc:date>2014-06-05T14:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extra rows when a .csv file is opened in Excel.</title>
      <link>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99782#M7739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Post your code so we can see what it's doing.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 14:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99782#M7739</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-06-05T14:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extra rows when a .csv file is opened in Excel.</title>
      <link>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99783#M7740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for responding Greg, I did find a solution.&amp;nbsp; As soon as I posted the question, I did another search on the internet and found the answer.&amp;nbsp; I have already tested it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I found is that when using .csv in Python the output file needs to be opened in binary mode.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code was like this:&amp;nbsp; open('DataFileComparison', 'w')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I set the file mode (sorry, not sure exactly what to call it yet) to 'wb'&amp;nbsp; it worked fine, no extra rows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is now:&amp;nbsp; open('DataFileComparison', 'wb')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dale,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 15:41:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99783#M7740</guid>
      <dc:creator>DaleShearer</dc:creator>
      <dc:date>2014-06-05T15:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extra rows when a .csv file is opened in Excel.</title>
      <link>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99784#M7741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I realize you mentioned that you are just starting, but its also good to be exposed to advanced (maybe) techniques too.&amp;nbsp; Here's an alternative way to write out feature classes and tables to .csv output files using arcpy.da, numpy and pandas libraries.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; import pandas as pd import numpy as np&amp;nbsp; fc = r'H:\Documents\ArcGIS\Default.gdb\MyFeatureClass'&amp;nbsp; #generate a list of fields flds = [f.name for f in arcpy.ListFields(fc)]&amp;nbsp; #you cannot include Shape/Geometry or Date fields in a NumPyArrray, so remove them from the field list flds.remove('Shape') #this is the geometry field in my FeatureClass flds.remove('START_TEST') #this is a date field in my FeatureClass&amp;nbsp; #convert to a NumPyArray nmpyarr = arcpy.da.TableToNumPyArray(fc, flds)&amp;nbsp; #convert to a Pandas DataFrame dfFC = pd.DataFrame(nmpyarr)&amp;nbsp; #Write the .csv file csv_out = r'H:\Documents\csvOUTPUT.csv' dfFC.to_csv(csv_out)&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 15:49:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99784#M7741</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-06-05T15:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extra rows when a .csv file is opened in Excel.</title>
      <link>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99785#M7742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi James, that is definitely an answer.&amp;nbsp; I do thank for the code you posted, I will give it a try as I continue in with Python.&amp;nbsp; Right now I am just happy it is working, once I get more knowledgeable of the code I will go from I can see what it is doing to knowing what it is doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you again.&amp;nbsp; Dale,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 15:59:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99785#M7742</guid>
      <dc:creator>DaleShearer</dc:creator>
      <dc:date>2014-06-05T15:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extra rows when a .csv file is opened in Excel.</title>
      <link>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99786#M7743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi James, that is definitely an answer.&amp;nbsp; I do thank for the code you posted, I will give it a try as I continue in with Python.&amp;nbsp; Right now I am just happy it is working, once I get more knowledgeable of the code I will go from I can see what it is doing to knowing what it is doing.&lt;BR /&gt;&lt;BR /&gt;Thank you again.&amp;nbsp; Dale,&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No problem.&amp;nbsp; It's a good idea to look at a diverse set of solutions as you may find need for them in the future.&amp;nbsp; It's perfectly fine to keep withint ESRI stack!&amp;nbsp; But I've had a lot of success incorporating 3rd party libraries into my GIS applications and glad I was exposed to alternative approaches --- I simply thought you might want that too!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Take care&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 16:44:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extra-rows-when-a-csv-file-is-opened-in-excel/m-p/99786#M7743</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-06-05T16:44:04Z</dc:date>
    </item>
  </channel>
</rss>

