You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
I perform the following read: df = pd.read_csv(fn, sep ='s,', skiprows=0, nrows = 1)
resulting in output:
%TITLE%
0 STC 190313/034000 -0.36,-25.61
where the latitude is -0.36, my intended value. In reading multiple files, the latitude value in the files can vary
in format from 0.0 (2 char), to -25.67 (6 char)
Apologies for the delayed response. I wouldn't use parse_csv to handle any of that header, only the later data. This is what I wrote to parse what you provided:
withopen(fn, 'rt') asinfile:
# skip "%TITLE%infile.readline()
# Get the siteid, date string, and lat/lon group by splitting on whitespacesite, date, latlon=infile.readline().split()
# Split the lat/lon group on a comma and convert to floatslat, lon=map(float, latlon.split(','))
# Skip blankinfile.readline()
# Get the column names from the names that *don't* have commascolumns=infile.readline().split()
# Let pandas parse the rest of the filedf=pd.read_csv(infile, skiprows=2, names=columns)
Activity
arunaskuciauskas commentedon Jan 28, 2022
Hi: I am trying to extract the latitude from hundreds of files that contain the following listing:
I perform the following read:
df = pd.read_csv(fn, sep ='s,', skiprows=0, nrows = 1)resulting in output:
where the latitude is -0.36, my intended value. In reading multiple files, the latitude value in the files can vary
in format from 0.0 (2 char), to -25.67 (6 char)
I applied a split on the '/' as:
resulting in output:
resulting in output:
lati: -0.1,The start of the latitude value always starts in the 7th position
Question: How can I make sure that I grab the entire latitude value?
dopplershift commentedon Feb 19, 2022
Apologies for the delayed response. I wouldn't use
parse_csvto handle any of that header, only the later data. This is what I wrote to parse what you provided: