Hello,
I am having some terrible issues getting data formatted in a way that is useful for me. All I am trying to do is read a file that has several points of data in comma delimited format, and break each line into multiple variables (just need to grab each variable separated by a comma, hopefully leaving it formatted as a string, and use it in another function). My current code is below, with a few lines of its output sitting below it. I dont know what the gibberish is, tho I image it has to do with wacky encoding issues as things got moved from windows to linux. Thanks and let me know if more info is needed. (o, i forgot to mention, when I look at my file using the command: [file textfile.txt], i get CURRENTTESTFILE: MPEG ADTS, layer I, v1, 96 kBits, 44.1 kHz, Stereo , which makes no sense...)
#!/usr/bin/env python
#Program to read comma delimited data in from a file and insert it
#into a prespecified table in psql
import os
import sys
import pgdb
import string
fa = open(datafilename, 'r')
for line in fa:
out = line.split(",")
print (out)
print (line)
fa.close()
brandon@xxxxx:/$ python TabelCreationModule.py
001,ADAMS COUNTY,99344,46.827354,-119.1742,COM,1592
001,ADAMS COUNTY,99344,46.827036,-119.173798,COM,1767
001,ADAMS COUNTY,99344,46.826063,-119.15651,COM,6500
001,ADAMS COUNTY,99344,46.826063,-119.169933,COM,16000
001,ADAMS COUNTY,99344,46.824922,-119.173798,COM,1320
001,ADAMS COUNTY,99344,46.824906,-119.173798,COM,3202
001,ADAMS COUNTY,99344,46.824874,-119.173798,COM,2400