I'm trying to open a txt file with 4605227 rows (305 MB)
The way I have done this before is:
data = np.loadtxt('file.txt', delimiter='\t', dtype=str, skiprows=1)
df = pd.DataFrame(data, columns=["a", "b", "c", "d", "e", "f", "g", "h", "i"])
df = df.astype(dtype={"a": "int64", "h": "int64", "i": "int64"})
But it's using up most of available ram ~10GB and not finishing. Is there a faster way of reading in this txt file and creating a pandas dataframe?
Thanks!
Edit: Solved now, thank you. Why is np.loadtxtx() so slow?