Home > Software design >  Reading a text file with pandas/numpy array
Reading a text file with pandas/numpy array

Time:11-10

Can anyone help me read and store this text file properly?

https://drive.google.com/file/d/1-o_M_nOSFU4J39Bczs4VfsCONrM-9l5w/view?usp=sharing

CodePudding user response:

This question is extremely vague and needs more detail in order for the question to be answered accurately. This includes clarification on what "proper" storage format of this file, and likely code that you have as an attempt to solve this problem yourself first.

CodePudding user response:

What stopping you read this file?

import pandas as pd
df = pd.read_fwf(r"D:\Downloads\INM00043333-data.txt", delimiter= '\s ')
print(df)
print(df.columns)

output #df

      #INM00043333 2016 02 06 00 0000  247 ncdc-gts   116667        927167
0      21 -9999 100100B -9999   234B -9999    31      36...           NaN
1      10 -9999 100000A   79B  230B -9999    38       5...            NaN
2      20 -9999  97800 -9999   234B -9999    25       25...           NaN
3      20 -9999  96400 -9999   250B -9999   110      -9999...         NaN
4      20 -9999  96000 -9999 -9999 -9999 -9999        50 ...          NaN
...                                                  ...         ...
90224  30 -9999  -9999   600 -9999 -9999 -9999        55 ...         NaN
90225  30 -9999  -9999   900 -9999 -9999 -9999        55 ...         NaN
90226  30 -9999  -9999  1800 -9999 -9999 -9999        70 ...         NaN
90227  30 -9999  -9999  2100 -9999 -9999 -9999        90 ...         NaN
90228  30 -9999  -9999  2400 -9999 -9999 -9999        85 ...         NaN

df # columns

Index(['#INM00043333 2016 02 06 00 0000  247 ncdc-gts   116667', '927167'], dtype='object')
  • Related