separating large txt file in pandas data frame or numpy
Question:
I am trying to split large .txt file on column
I tried
Using numpy cutoff my data to scientific notation
"
df = np.loadtxt(‘data1.txt’]
dy = pd.DataFrame(df, columns=[‘X_Y’, ‘X’,’Y’, ‘time’,’weight’])
"
I tried converting the numpy array into dataframe as well but didn’t worked
"
- A B C D E
- 0 6.751537323 260556.2188 5.107021332 1640995201.0 1.0
- 1 4.755306244 260556.2188 5.101299286 1640995202.0 2.0
- 2 6.725025177 260556.2188 5.110740662 1640995204.0 1.0
- 3 6.008720398 260556.2188 5.105113983 1640995205.0 1.0
- 4 6.849765778 260556.2188 5.105304718 1640995206.0 2.0
- 5 6.798267365 260556.2188 5.10225296 1640995208.0 1.0
- 6 4.688739777 260556.2188 5.112838745 1640995209.0 1.0
"
Answers:
This solved my issue
df = pd.read_csv("filename.txt", sep = " ", columns = ['A','B','C','D'])
Thank You so much
I am trying to split large .txt file on column
I tried
Using numpy cutoff my data to scientific notation
"
df = np.loadtxt(‘data1.txt’]
dy = pd.DataFrame(df, columns=[‘X_Y’, ‘X’,’Y’, ‘time’,’weight’])
"
I tried converting the numpy array into dataframe as well but didn’t worked
"
- A B C D E
- 0 6.751537323 260556.2188 5.107021332 1640995201.0 1.0
- 1 4.755306244 260556.2188 5.101299286 1640995202.0 2.0
- 2 6.725025177 260556.2188 5.110740662 1640995204.0 1.0
- 3 6.008720398 260556.2188 5.105113983 1640995205.0 1.0
- 4 6.849765778 260556.2188 5.105304718 1640995206.0 2.0
- 5 6.798267365 260556.2188 5.10225296 1640995208.0 1.0
- 6 4.688739777 260556.2188 5.112838745 1640995209.0 1.0
"
This solved my issue
df = pd.read_csv("filename.txt", sep = " ", columns = ['A','B','C','D'])
Thank You so much