'How to read and convert files of same naming convention into dataframe and add a date column from the filename?
Connecting to SSH on python to read through a directory of gz files using unix command. The converting into df and adding a date column from the filename (filename is constantly abcdate.gz)
def run_cmd(cmd):
connection = ssh(client, user, password)
a = connection.sendCommand(cmd)
return a
b = run_cmd("less /path/abc20131213.gz")
df = pd.read_csv(io.BytesIO(b))
df.head()
A B
0 I915 0.12
1 O975 0.33
2 Z913 0.07
3 I567 0.15
4 A347 0.85
The initial conversion works. How do I read through the directory in a loop and append the data into df and add a new 'date' column based on the filename?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
