Untitled
user_3839718
python
2 years ago
491 B
5
Indexable
import pandas as pd
file_path = "TCORISEAGLES165Mw.tok"
data = []
with open(file_path, "r") as file:
for line_number, line in enumerate(file, start=1):
parts = line.strip().split()
count = parts[0]
try:
word = parts[1]
except IndexError:
print(f"Error at line {line_number}: {word}")
continue
data.append({"count": count, "word": word})
df = pd.DataFrame(data)
df.to_csv("TCORISEAGLES165Mw.csv", index=False)Editor is loading...
Leave a Comment