0

Everything looks to be fine here but still i'm seeing a very different error. Can anyone suggest what is flaw in my code as i'm able to execute it if i omit the to_csv

import pandas as pd
import pyodbc

con= pyodbc.connect("connection")

fr1=pd.read_csv("C:\folder\file1.csv")
fr2=pd.read_csv("C:\folder\file2.csv")

fr=pd.concat([df1,df2])
fr3=pd.read_sql_query(" select name, addr as ID from newtable", con )
result= pd.merge(fr3, fr, left_on='ID', right_on='URL', how='right')
matchset=result[result.ID.isnull()].to_csv("C:\match.csv")
nomatch=result[result.ID.notnull()].to_csv("C:\nomatch.csv")

Error:

**OSError [Errno 22] Invalid argument:'C:\match.csv' **

1 Answers1

0

\\ instead of \ solved the error.

David Buck
  • 3,752
  • 35
  • 31
  • 35
  • Glad the issue is solved. May I recommend using `/` instead; as this aids in portability for relative paths across *nix and Win systems. – S3DEV Aug 11 '20 at 17:44
  • thank david. Could you please review this code and help me understand were my error is? i've been trying to fix this from morning but not working https://stackoverflow.com/questions/63355040/how-to-compare-csv-data-with-sql-dataset-pandas –  Aug 11 '20 at 17:48