Python Forum
How to automate list separation. NOOB
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to automate list separation. NOOB
#16
That looks very promising.
An enormous thank you Big Grin Dance Heart for the work you put into this. I'm looking forward to trying it out. I will advise.

>>> stations = [21413, 21414,   21415,   21416,   21417,   21418,   21419,   21420]
 
maximums = []
 
for station in stations:
  for year in range(2010, 2018):
    try:
      filename = f'https://www.ndbc.noaa.gov/view_text_file.php?filename={station}t{year}.txt.gz&dir=data/historical/dart/'
      df = pd.read_csv(filename, sep='\s+',header=None,skiprows=2, names=['height'],usecols=[7]).query('height != 9999.0').max()[0]
      maximums.append(df)
    except:
      print(f'Missing: station {station}, year: {year}')
      continue
SyntaxError: multiple statements found while compiling a single statement
I seem to be getting this syntax error often. I'm using Python 3.6.8. It did this when I tried some code in an exercise and I don't know why.
Reply


Messages In This Thread
RE: How to automate list separation. NOOB - by LobateScarp - Sep-23-2019, 03:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Automate the boring stuff, inserting commas in list srikanth 1 2,132 Jul-02-2019, 02:29 PM
Last Post: metulburr
  Automate the boring stuff, inserting commas in list DJ_Qu 3 4,724 Apr-21-2019, 03:52 PM
Last Post: perfringo
  1. How can I automate this batch creation of documents? 2. How can I automate posting SamLearnsPython 2 3,444 Jul-02-2018, 11:36 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020