(Jan-11-2022, 10:03 AM)amdi40 Wrote:(Jan-10-2022, 12:01 PM)Larz60+ Wrote: 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
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
Thanks for the reply, I think I might have been unclear in what I wanted to get help with. My problem is that the current time in the file is wrong. The timestep between each line should be 2 minutes but is as of now 0, and then when a new event is recorded it switches to that timestamp and then the time remains constant. You have already helped a lot with this in another post https://python-forum.io/thread-35960-pos...#pid151576 which I am very thankful for!. The problem here is however that the data for minutes went over 60:
19790111 1061 1.667
should be:
19790111 1101 1.667
In order to fix this, I thought I could remove the next function you made, so the timestep would become constant for each recorded event, and then add a deltatime to each timestep after. i can however not figure out how to do it
change item in column based on the item before[solved]
Messages In This Thread |
change item in column based on the item before[solved] - by amdi40 - Jan-10-2022, 11:22 AM
RE: change item in column based on the item before - by Larz60+ - Jan-10-2022, 12:01 PM
RE: change item in column based on the item before - by amdi40 - Jan-11-2022, 10:03 AM
RE: change item in column based on the item before - by amdi40 - Jan-11-2022, 10:05 AM
RE: change item in column based on the item before[solved] - by amdi40 - Jan-11-2022, 04:50 PM
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
removing item | pastakipp | 3 | 1,974 |
Oct-25-2020, 09:15 PM Last Post: deanhystad |
|
Python Adding +1 to a list item cointained in a dict | ElReyZero | 1 | 2,136 |
Apr-30-2020, 05:12 AM Last Post: deanhystad |
|
need help removing an item from a list | jhenry | 4 | 4,280 |
Oct-13-2017, 08:15 AM Last Post: buran |
|
Determine if a list contains a specific number of an item | flannel_man | 3 | 5,010 |
Nov-12-2016, 04:46 PM Last Post: micseydel |
Users browsing this thread: 1 Guest(s)