isudatateam / datateam

File opened without the with statement PTC-W0010
Anti-pattern
Critical
3 months ago3 months old
Use the with statement to open a file
20        "tmax": row[3],
21        "tmin": row[4],
22    }
23o = open("kbs_century.txt", "w")24
25for year in range(1951, 2013):
26    for col in ["prec", "tmin", "tmax"]:
Use the with statement to open a file
105        worksheet.freeze_panes(3, 0)
106
107    fn = ",".join(stations)
108    res = open("/tmp/ss.xlsx", "rb").read()109    os.unlink("/tmp/ss.xlsx")
110    return res, fn
111
Use the with statement to open a file
180                df.to_excel(writer, sheet_name="Data", index=False)
181                worksheet = writer.sheets["Data"]
182                worksheet.freeze_panes(3, 0)
183            payload = open("/tmp/ss.xlsx", "rb").read()184            os.unlink("/tmp/ss.xlsx")
185            return [payload]
186
Use the with statement to open a file
109                df.to_excel(writer, sheet_name="Data", index=False)
110                worksheet = writer.sheets["Data"]
111                worksheet.freeze_panes(3, 0)
112            payload = open("/tmp/ss.xlsx", "rb").read()113            os.unlink("/tmp/ss.xlsx")
114            return [payload]
115
Use the with statement to open a file
171                df.to_excel(writer, sheet_name="Data", index=False)
172                worksheet = writer.sheets["Data"]
173                worksheet.freeze_panes(3, 0)
174            payload = open("/tmp/ss.xlsx", "rb").read()175            os.unlink("/tmp/ss.xlsx")
176            return [payload]
177