Skip to content

Instantly share code, notes, and snippets.

@jskherman
Last active January 25, 2022 02:35
Show Gist options
  • Save jskherman/9f91be0d6b08d9710382c23d39335dea to your computer and use it in GitHub Desktop.
Save jskherman/9f91be0d6b08d9710382c23d39335dea to your computer and use it in GitHub Desktop.
Script to parse the generated CSV from the Forest App into a pandas dataframe
# Script to parse the csv from the Forest App into a pandas dataframe
#%%
import pandas as pd
from datetime import datetime
### Specify pattern for dates in Forest's csv export for dateparser
dateparse = lambda x: datetime.strptime(x, "%a %b %d %H:%M:%S %Z%z %Y")
### Sidenote: Alternative regex patterns
### (1) "%a %b %d %H:%M:%S GMT+08:00 %Y"
### (2) "%a %b %d %H:%M:%S %Z%z %Y"
#%%
### Read the CSV
df = pd.read_csv("Plants.csv", parse_dates=["Start Time", "End Time"], date_parser=dateparse)
df.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment