Created
May 29, 2019 17:13
-
-
Save cirops/ef08763deed628a522288b0d40408bb3 to your computer and use it in GitHub Desktop.
Sample query for the CNPJ sqlite3 database
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 sqlite3 | |
import csv | |
import pandas as pd | |
def main(): | |
database_file = "CNPJ_full.db" | |
conn = conn = sqlite3.connect(database_file) | |
df = pd.read_sql_query("SELECT * FROM empresas WHERE municipio='PELOTAS'", conn) | |
df.to_csv('cnpj_empresas_pelotas.csv', quotechar='"', quoting=csv.QUOTE_NONNUMERIC, index=False, encoding='utf-8') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment