Jan-10-2022, 12:01 PM
Your code can be greatly simplified.
The following opens the input spreadsheet you supplied, and writes it back out as a csv.
It does nothing to modify the data, you will have to add that.
The print statement only shows what was read and should be removed when statisfied
The following opens the input spreadsheet you supplied, and writes it back out as a csv.
It does nothing to modify the data, you will have to add that.
The print statement only shows what was read and should be removed when statisfied
import os import pandas as pd # make sure starting directory set os.chdir(os.path.abspath(os.path.dirname(__file__))) n = 2 df = pd.read_excel("newfile1.xlsx", dtype=str) print(df) pd.to_csv('newfile2.csv')
Output: datetime,intensity
0 19790111-1007,3.333
1 19790111-1007,3.333
2 19790111-1007,3.333
3 19790111-1007,0.556
4 19790111-1007,0.556
5 19790111-1007,0.556
6 19790111-1007,0.556
7 19790111-1007,0.556
8 19790111-1007,0.556
9 19790111-1007,3.333
10 19790111-1007,0.370
11 19790111-1007,0.370
12 19790111-1007,0.370
13 19790111-1007,0.370
14 19790111-1007,0.370
15 19790111-1007,0.370
16 19790111-1007,0.370
17 19790111-1007,0.370
18 19790111-1007,0.370
19 19790111-1007,0.476
20 19790111-1007,0.476
21 19790111-1007,0.476
22 19790111-1007,0.476
23 19790111-1007,0.476
24 19790111-1007,0.476
25 19790111-1007,0.476