Hello. I’m wondering if anyone could help me. I’ve tried \n and os.linsep and I cannot get a line break working. I’m brand new to Python and havent coded since Visual Basic 6 back in the 90s.
I’m trying to output “IconStatement” with line breaks?
import os
import xarray as xr
from glob import glob
num_of_files = 3
glmFiles = glob(f'OR_GLM-L2-LCFA_G16_*.nc')
print(glmFiles)
flash_data = []
updateTime = None
for i in range(num_of_files):
if i < len(glmFiles):
ds = xr.open_dataset(glmFiles[-i])
if updateTime == None or updateTime <= ds.product_time.data:
updateTime = ds.product_time.data
for lat, lon in zip(ds.flash_lat.data, ds.flash_lon.data):
lon = float(lon)
lat = float(lat)
IconStatement = "Icon: " + str(lat) + ", " + str(lon) + ", 1, 1, 16, 16" + os.linesep
flash_data.append((IconStatement))
with open(f'glm_strikes.txt', 'w') as f:
data = (flash_data)
f.write(str(data))
with open(f'glm_update.txt', 'w') as f:
f.write(str(updateTime))
Perfect! That code worked and I now have a better understanding of what I was doing wrong and learned something new. Thank you very much and have a great day.
Oh, very nice! Thank you for your help. I rewrote some of my coding with your suggestions and added other things I needed and it’s working great.
My code is pulling lightning data from GOES satellite and making it available for free, for the public’s use, using expensive GR2Analyst & WSV3 software. High end weather software. So I really thank you and so do about 170 unique ips (users) of my data. Thank you!