csv.reader problem tab-delimiter - newbie
Clovis Fabricio
nosklo at gmail.com
Tue Oct 21 13:50:02 EDT 2008
2008/10/21 <hidding at uni-duesseldorf.de>:
> grrr thanks George, thanks Daniel, that's it. Works fine with real
> tabs. Now this brings me to a follow-up: I have not prepared the input
> ascii file, I just got if for post-processing (23 MB). Now it seems
> that I would have to replace all series of spaces in this file with
> real tabs at first.. How would you do that? Are there text editors
> capable of doing this?
If the file you got isn't really tab delimited, you shouldn't convert
it to a tab delimited file before processing.
Just process it as it is, a multiple-space-delimited file.
f = open('file.txt')
for line in f:
line = line.strip().split()
# do whatever with data
print line
f.close()
Clóvis
More information about the Python-list
mailing list