Tag: File
How to read data from a csv file in C++ ?
In this article we will discuss and create a class to read data from a CSV File. What is a CSV File ? A csv file is a kind of flat file used to store the data. In this each row contains data separated by comma. For example, Advertisements 20,hi,99 3,4,5 a,b,c 3,4,1 Creating a …
How to write data in a CSV file in C++
In this article we will discuss, how to create a class to write data to a CSV File. What is a CSV File ? A CSV file is a kind of flat file used to store the data. In this each row contains data separated by comma. For example, Advertisements 20,hi,99 3,4,5 a,b,c 3,4,1 Creating …
C++ : How to read a file line by line into a vector ?
In this article we will discuss how to read a file line by line and put them in a vector or perform some other operation each line. Reading File line by line First open the file i.e. Advertisements // Open the File std::ifstream in(“file.txt”); Now keep reading next line using getline() and push it in …
C++ : How to read a file line by line into a vector ?Read More
C++ : How to read or write objects in file | Serializing & Deserializing Objects
In this article we will discuss how to write objects to file and how to read them back from to file and fill in object. Suppose we have a class Student i.e. class Student { public: std::string mName; std::string mId; std::string mPhoneNumber; Student(std::string id = “”, std::string name = “”, std::string phone = “”) : …
C++ : How to read or write objects in file | Serializing & Deserializing ObjectsRead More
C++ : Check if given path is a file or directory using Boost & C++17 FileSystem Library
In this article we will discuss different ways to check if given path is of file or directory that exists using Boost Filesystem Library & C++17 Filesystem Library. Both Boost Filesystem library & C++17 Experimental filesystem library provides certain functions that we are going to use here, Advertisements bool exists(const path& p); In Boost Library’s …
C++ : Check if given path is a file or directory using Boost & C++17 FileSystem LibraryRead More
C++: How to extract file extension from a path string using Boost & C++17 FileSystem Library
In this article we will dicuss different ways to extract extension from a given path string using different technique i.e. C++17 FileSystem Library Boost FileSystem Library C++ STL Suppose given file is, Advertisements /home/user/sample/temp/logs.out It’s extension should be .out. Fetch extension of a given file using Boost Filesystem Library & C++17 Both boost filesystem library …
How to check if a file or directory or link exists in Python ?
In this article we will discuss techniques in python to check if a file exists or a link or a directory exists or not. Python – Check if a path exists Python’s os module provides a function to check if a given path exists or not i.e. Advertisements os.path.exists(path) It will True if the path …
How to check if a file or directory or link exists in Python ?Read More
Read a file line by line in Python (5 Ways)
In this article we will discuss different ways to read a file line by line in Python. Suppose we have a file data.txt in same directory as our python script. Let’s see how to read it’s contents line by line. Solution for Small Files : Get list of all lines in file using readlines() First …
Python : Get Last Modification date & time of a file. | os.stat() | os.path.getmtime()
In this article we will discuss different ways to get the last modification date & time of a file and how to convert them into different formats. Get last modification time of a file using os.stat() os.stat(pathOfFile) It returns the status of file in the form of an os.stat_result object. It contains information related to a …
Python : Get Last Modification date & time of a file. | os.stat() | os.path.getmtime()Read More
Python : How to get Last Access & Creation date time of a file
In this article we will discuss different ways to get the last access and creation timestamp of a file and how to convert them into different formats. os.stat() Python’s os module provides a function os.stat() Advertisements os.stat(pathOfFile) It accepts the path of file as argument and returns the status of file in the form of an …
Python : How to get Last Access & Creation date time of a fileRead More