Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas to csv if no already present

import glob
import pandas as pd

# Give the filename you wish to save the file to
filename = 'Your_filename.csv'

# Use this function to search for any files which match your filename
files_present = glob.glob(filename)


# if no matching files, write to csv, if there are matching files, print statement
if not files_present:
    pd.to_csv(filename)
else:
    print 'WARNING: This file already exists!'
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #csv #present
ADD COMMENT
Topic
Name
2+5 =