Nov-29-2022, 12:00 AM
Hi Deanstyed,
great solution ,
but still unable to utilise correctly in my situation.
I dont want this ------>range(2, 14, 2)
I am ok for 0.0 value.
input data there are 300 columns to check , where is zero value
xyz 29-11-2022 0.0000000000 1.00002
abc 29-11-2022 0.000000000 200
expected output now
xyz | 29-11-2022| 0.0| 1.00002
abc | 29-11-2022| 0.0| 200
rows = [[Decimal(f'0E-{x}'), Decimal(f'1.2E-{x+1}')] for x in range(2, 14, 2)]
with open("test.csv", "w", newline="") as file:
writer = csv.writer(file, quoting=csv.QUOTE_NONE, delimiter="|")
for row in rows:
writer.writerow(map(lambda x: f'{x.normalize():f}', row))
#-----My Code----------
great solution ,
but still unable to utilise correctly in my situation.
I dont want this ------>range(2, 14, 2)
I am ok for 0.0 value.
input data there are 300 columns to check , where is zero value
xyz 29-11-2022 0.0000000000 1.00002
abc 29-11-2022 0.000000000 200
expected output now
xyz | 29-11-2022| 0.0| 1.00002
abc | 29-11-2022| 0.0| 200
rows = [[Decimal(f'0E-{x}'), Decimal(f'1.2E-{x+1}')] for x in range(2, 14, 2)]
with open("test.csv", "w", newline="") as file:
writer = csv.writer(file, quoting=csv.QUOTE_NONE, delimiter="|")
for row in rows:
writer.writerow(map(lambda x: f'{x.normalize():f}', row))
#-----My Code----------
while True: rows = cursor.fetchmany(10000) if len(rows) == 0: print("no records found") break else: for row in rows: #writer.writerows(row) instead of this line , # just to replace single line , I am writing more line for row in rows: for x in row: no = float(x) if no ==0: writer.writerows(row)