简体   繁体   中英

What replaces the asterisk in Python?

I'm using psycopg2 to copy csvs into postgres. all my csvs will always have the same suffix, such as competitors or customers, along with a unique number each time i generate them. therefore I want a python script that can run to use COPY and I can just have 'dir/customers*.csv'

is there an easy way to do this, does asterisk exist as some other character in python?

Thanks in advance!

Ok so what I currently have is a geoprocessing model in ArcGIS that will generate a bunch of CSVs into C:\\Data\\Sheltered BLPUs\\CSVs such as competitors and customers, but attaches a unique ID for each location onto the end of the filename eg customers17.csv. I then want a python script to copy all of these into postgres. All the tables exist as 'customers' or 'competitors' - this is what I wanted to write:

cur.execute("COPY competitors FROM 'C:/Data/Sheltered BLPUs/CSVs/competitors*.csv' DELIMITER ',' CSV;")

import glob
print glob.glob('dir/customers*.csv')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM