Jul-04-2017, 09:12 PM
I would guess it means that you have posted different "csv" file than you are actually processing...
Your posted output was probably pandas dataframe output (with line numbers and fields unquoted and separated by whitespaces), while your actual file seems to be real csv file with comma separator and quoted fields:
As it seems that you are working with real csv file, use csv module - something like
Your posted output was probably pandas dataframe output (with line numbers and fields unquoted and separated by whitespaces), while your actual file seems to be real csv file with comma separator and quoted fields:
Output:"FIPS","text"
1001,"I screwed that last tweet upAnd im ready to get..."
1003,"Like, please, we're all dying to know how many..."
...
If you process such file with DeaD_Eye's script, you naturally would get strange file names (anything to first whitespace would be in file name) and shortened text (and Dead_Eye's script would not survive file with line consisting just of whitespaces, but that should not be problem in "well" formatted csv).As it seems that you are working with real csv file, use csv module - something like
import csv with open('file.csv') as csvfile: reader = csv.reader(csvfile) next(reader) # throw away first line for row in reader: # row is already list of splitted fields if len(row) == 2: # write out only lines that have exactly two fields - id and tweet? with open(row[0] + ".txt", "w") as outfile: outfile.write(row[1] + "\n")If your file can contain more than two fields and you want them all, concatenate row[1:] into your output file (or use csv.writer and write csv file). And if you want to write out even "empty" tweets, then add check for len(row) == 1 writing empty file...