-
-
Save sany2k8/abfe3f4427d83ef8ea83576fcc81d30a to your computer and use it in GitHub Desktop.
Pandas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| # Read file | |
| results = pd.read_csv("/tmp/data.csv", encoding='utf-8',sep=',', quoting=csv.QUOTE_ALL) | |
| # Print rows | |
| for row in results: | |
| print(row) | |
| # Iterate over rows | |
| for index, row in data.iterrows(): | |
| print(row) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cx_Oracle | |
| import pandas as pd | |
| # Create connection | |
| connection = cx_Oracle.connect(CONN_STRING) | |
| cursor = connection.cursor() | |
| cursor.execute("SELECT * FROM TABLE") | |
| # Grab metadata | |
| csv_heading = [col[0] for col in cursor.description] | |
| # Grab results | |
| results = cursor.fetchall() | |
| # Write results to `CSV` | |
| pd.DataFrame(results, columns=csv_heading).to_csv("/tmp/data.csv", index=False, encoding='utf-8',sep=',', quoting=csv.QUOTE_ALL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment