|
10,10,50,50,10
|
import csv
f = open('data.csv', newline='')
reader = csv.reader(f, quoting=csv.QUOTE_NONNUMERIC)
for row in reader: # A list of rows
for value in row: # A list of value
print(value) # Floats
f.close() # Don't close until you are done with the reader;
# the data is read on request.
dialect='excel-tab'
to the reader to open tab-delimited files.
f2 = open('dataout.csv', 'w', newline='')
writer = csv.writer(f2, delimiter=' ')
for row in data:
writer.writerow(row) # List of values.
f2.close()
|
|
<HTML>
<BODY>
<P><B>This</B> is<BR>text
</BODY>
</HTML>
import json
Numbers are converted to floats etc.
|
|
{'features':
|
JSON: object array string number (int) number (real) true false null |
Python: dict list str int float True False None |
import json
f = open('data.json')
data = json.load(f)
f.close()
f = open('out.json', 'w')
json.dump(data, f)
f.close()
print(json.dumps(data["features"][0]["geometry"], sort_keys=True, indent=4))
"geometry": {
"coordinates": [
42.0,
21.0
],
"type": "Point"
}
python -m json.tool < data.json