
Spent 2 hours debugging CSV import. Turns out Excel added invisible characters.
Spent 2 hours debugging CSV import. Turns out Excel added invisible characters. Client sent me a CSV file yesterday. Simple product list with prices. Import it into my Python script and half the rows fail validation. Opened the CSV in a text editor. Everything looks fine. Columns are there. Data looks clean. Run the script again. Same errors. What broke My script was parsing product prices like this: import csv with open ( ' products.csv ' , ' r ' ) as f : reader = csv . DictReader ( f ) for row in reader : try : price = float ( row [ ' Price ' ]) print ( f " { row [ ' Product ' ] } : $ { price } " ) except ValueError : print ( f " Failed: { row [ ' Product ' ] } - Bad price: ' { row [ ' Price ' ] } '" ) Output showed weird stuff: Product A: $19.99 Failed: Product B - Bad price: '29.99' Product C: $39.99 Failed: Product D - Bad price: '49.99' The prices that failed looked identical to the ones that worked. Copy pasted them into the Python REPL. Worked fine there. Fun. Figured it out ev
Continue reading on Dev.to Python
Opens in a new tab


![[MM’s] Boot Notes — The Day Zero Blueprint — Operations from localhost to production without panic](/_next/image?url=https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1433%2F1*cD3LWDy_XXNTdZ_8GYh6AA.png&w=1200&q=75)

