I have a python code that reads several csv files and writes teh data to a single file but every time it loops back around to the next file it prints the headers again. Is there a way to stop this I can post my code if it is nessisary.
abaddon2031
0
Junior Poster in Training
Recommended Answers
Jump to PostYou can read and ignore the first line of other than the first file. I assume then form of these files is exactly same. Something similar to:
def files_to_one(new_file, *files): with open(new_file, 'w') as fout: for fileno, fn in enumerate(files): with open(fn) as fin: print fileno, fn …
All 4 Replies
TrustyTony
888
pyMod
Team Colleague
Featured Poster
snippsat
661
Master Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
abaddon2031
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.