<?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: float argument in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/float-argument/m-p/52872#M4201</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please test your script using the top 5 lines of your CSV file, if it does not work, then please add these few lines here for us to solve!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(We think it may be your CSV data, for example you may be trying to save a "String" inside a "Number" field?)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Sep 2015 14:24:01 GMT</pubDate>
    <dc:creator>LukeWebb</dc:creator>
    <dc:date>2015-09-18T14:24:01Z</dc:date>
    <item>
      <title>float argument</title>
      <link>https://community.esri.com/t5/python-questions/float-argument/m-p/52867#M4196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CSV file converted from geodatabase is red in my script and it keeps cause an error regarding float argument as all the items in the data file are strings. I was seeking a few ways to add argument, but it does not work well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please provide any suggestion or solution?&lt;/P&gt;&lt;P&gt;Just in case, I upload a part of my script. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import csv&lt;BR /&gt;from pulp import *&lt;/P&gt;&lt;P&gt;supplyData = {}&lt;BR /&gt;with open('C:\\scripts\\oil_sd.csv') as csvfile:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reader = csv.DictReader(csvfile)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in reader:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; supplyData[row['originid']] = [row['oilseed'], 0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Sep 2015 16:44:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/float-argument/m-p/52867#M4196</guid>
      <dc:creator>HyunjuJeong1</dc:creator>
      <dc:date>2015-09-11T16:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: float argument</title>
      <link>https://community.esri.com/t5/python-questions/float-argument/m-p/52868#M4197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What exactly is the error? This seems to work for me with my own csv.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Sep 2015 18:17:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/float-argument/m-p/52868#M4197</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-09-11T18:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: float argument</title>
      <link>https://community.esri.com/t5/python-questions/float-argument/m-p/52869#M4198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course a few lines of the csv file would provide a nice context to assess your script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Sep 2015 18:17:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/float-argument/m-p/52869#M4198</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-09-11T18:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: float argument</title>
      <link>https://community.esri.com/t5/python-questions/float-argument/m-p/52870#M4199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got this error. "TypeError: float argument required, not str"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, the script that I attached has no problem itself. I believe that the data imported from CSV used in a linear programming calculation could cause the issue. And I also wonder your csvfile has texts...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I upload all the entire script just for clarifying my issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import csv&lt;BR /&gt;from pulp import *&lt;/P&gt;&lt;P&gt;supplyData = {}&lt;BR /&gt;with open('C:\\scripts\\oil_sd.csv') as csvfile:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reader = csv.DictReader(csvfile)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in reader:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; supplyData[row['originid']] = [row['oilseed'], 0]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;demandData = {}&lt;BR /&gt;with open('C:\\scripts\\fu_stn.csv') as csvfile:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reader = csv.DictReader(csvfile)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in reader:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; demandData[row['destinationid'])] = [0, row['oilseed']]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;nodeData = {}&lt;BR /&gt;nodeData = dict(supplyData.items() + demandData.items())&lt;BR /&gt;Nodes = [(b) for b in nodeData.keys()]&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;arcData = {}&lt;BR /&gt;with open('C:\\scripts\\route.csv') as csvfile:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reader = csv.DictReader(csvfile)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in reader:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcData[row["originid"], row["destinationid"]]=[row['cost'], row['min'], row['max']]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Arcs =[(k) for k in arcData.keys()]&lt;/P&gt;&lt;P&gt;(supply, demand) = splitDict(nodeData)&lt;BR /&gt;(costs, mins, maxs) = splitDict(arcData)&lt;/P&gt;&lt;P&gt;vars = LpVariable.dicts("Route",Arcs,None,None,LpInteger)&lt;/P&gt;&lt;P&gt;for a in Arcs:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vars&lt;A&gt;.bounds(mins&lt;/A&gt;&lt;A&gt;, maxs&lt;/A&gt;&lt;A&gt;)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;prob = LpProblem("Supply Chain Problem",LpMinimize)&lt;/P&gt;&lt;P&gt;prob += lpSum([vars&lt;A&gt;* int(costs&lt;/A&gt;&lt;A&gt;) for a in Arcs]), "Total Cost of Transport"&lt;/A&gt;&lt;/P&gt;&lt;P&gt;prob.writeLP("OilseedSupplyChain.lp")&lt;/P&gt;&lt;P&gt;prob.solve()&lt;/P&gt;&lt;P&gt;print("Status:", LPStatus[prob.status])&lt;/P&gt;&lt;P&gt;for v in prob.variables():&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(v.name, "=", v.varValue)&lt;/P&gt;&lt;P&gt;print("Total Cost of Transportation = ", value(prob.objective))&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Sep 2015 18:30:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/float-argument/m-p/52870#M4199</guid>
      <dc:creator>HyunjuJeong1</dc:creator>
      <dc:date>2015-09-11T18:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: float argument</title>
      <link>https://community.esri.com/t5/python-questions/float-argument/m-p/52871#M4200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I uploaded my entire script as the reply for the first comment. I wish it can clarify the issue of my script.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Sep 2015 18:31:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/float-argument/m-p/52871#M4200</guid>
      <dc:creator>HyunjuJeong1</dc:creator>
      <dc:date>2015-09-11T18:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: float argument</title>
      <link>https://community.esri.com/t5/python-questions/float-argument/m-p/52872#M4201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please test your script using the top 5 lines of your CSV file, if it does not work, then please add these few lines here for us to solve!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(We think it may be your CSV data, for example you may be trying to save a "String" inside a "Number" field?)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2015 14:24:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/float-argument/m-p/52872#M4201</guid>
      <dc:creator>LukeWebb</dc:creator>
      <dc:date>2015-09-18T14:24:01Z</dc:date>
    </item>
  </channel>
</rss>

