title: Python ValueError: malformed node or string: <_ast.Name object at
body: <p>Hi guys I am geting all the time an error that freaks me out cause I have allready had a similar code where it doesnt make any Problems. I guess it is because the ast.literal_eval but in my other code for a Geolocation it works fine, the only difference here is that i have 8 coordinats instead of 2 in my working code.</p>
  
  <pre><code>from __future__ import print_function
  from shapely.wkt import loads as load_wkt
  from shapely.geometry import Point, Polygon
  import re
  import ast
  import io
  
  with io.open('sample_test1.txt', encoding="utf-8") as f, io.open('sample_test2.txt.txt', 'w',encoding="utf-8") as g:
          for line in f:
                  j = re.sub(r'.*(\[.*\]).*', r'\1', line.rstrip())
                  k = ast.literal_eval(j)
                  p = Polygon(k)
                  c = p.centroid
                  print (c, file = g)
  f.close()
  g.close() 
  </code></pre>
  
  <p>The data that the re.sub catches look like this:</p>
  
  <pre><code>[(38.78866,-75.56358),(41.357426,-75.56358),(41.357426,-73.88506),(38.78866,-73.88506)]
  </code></pre>
  
  <p>Here the original input:</p>
  
  <pre><code>703971723738288128,[(39.87181,-75.28028),(40.13792,-75.28028),(40.13792,-74.95571),(39.87181,-74.95571)],,,lmao maybe but I probably listened to TLOP almost everyday so I heard everyone song at least 10 times ðŸ˜­
  703971724577148928,[(37.88661,-79.48765),(39.72362,-79.48765),(39.72362,-74.98628),(37.88661,-74.98628)],,,Whose trying to come out and enjoy this beautiful weather?
  703971724635852800,[(39.87181,-75.28028),(40.13792,-75.28028),(40.13792,-74.95571),(39.87181,-74.95571)],21886583,WorkFromHomeQ102Meet5H,I just got home from work now I'm listening to #WorkFromHome ðŸ˜œ #Q102Meet5H @Q102Philly
  </code></pre>
  
  <p>I keep geting all the time this error: </p>
  
  <pre><code>File "polygon_csv.py", line 30, in &lt;module&gt;
      k = ast.literal_eval(j)
    File "...\Anaconda3\lib\ast.py", line 84, in literal_eval
      return _convert(node_or_string)
    File "...\Anaconda3\lib\ast.py", line 55, in _convert
      return tuple(map(_convert, node.elts))
    File "...\Anaconda3\lib\ast.py", line 83, in _convert
      raise ValueError('malformed node or string: ' + repr(node))
  ValueError: malformed node or string: &lt;_ast.Name object at 0x00000203D2EA0F98&gt;
  </code></pre>