Pandas to_csv() checking for overwrite

Try the following: 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: … Read more

How to get list of files with a specific extension in a given folder?

#define BOOST_FILESYSTEM_VERSION 3 #define BOOST_FILESYSTEM_NO_DEPRECATED #include <boost/filesystem.hpp> namespace fs = boost::filesystem; /** * \brief Return the filenames of all files that have the specified extension * in the specified directory and all subdirectories. */ std::vector<fs::path> get_all(fs::path const & root, std::string const & ext) { std::vector<fs::path> paths; if (fs::exists(root) && fs::is_directory(root)) { for (auto const & … Read more

NSFileManager unique file names

Create your own file name: CFUUIDRef uuid = CFUUIDCreate(NULL); CFStringRef uuidString = CFUUIDCreateString(NULL, uuid); CFRelease(uuid); NSString *uniqueFileName = [NSString stringWithFormat:@”%@%@”, prefixString, (NSString *)uuidString]; CFRelease(uuidString); A simpler alternative proposed by @darrinm in the comments: NSString *prefixString = @”MyFilename”; NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString] ; NSString *uniqueFileName = [NSString stringWithFormat:@”%@_%@”, prefixString, guid]; NSLog(@”uniqueFileName: ‘%@'”, uniqueFileName); NSLog … Read more

Remove all files in a directory

os.remove() does not work on a directory, and os.rmdir() will only work on an empty directory. And Python won’t automatically expand “/home/me/test/*” like some shells do. You can use shutil.rmtree() on the directory to do this, however. import shutil shutil.rmtree(‘/home/me/test’) be careful as it removes the files and the sub-directories as well.

How to preserve files original creation date?

Use scp with the -p option. -p Preserves modification times, access times, and modes from the original file. Example command copying a file from local to remote server: scp -p /home/mylocaldata/test.txt remote.example.com:/home/remote_dir Note that this will not preserve user and group only permission flags (rwx and such).

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)