• Python copy file to another directory
    17 January

    How to copy file to another directory in Python

    In this article, we will see different ways to copy file to another directory in Python. We can read and write files in Python. We can also work with paths and directories using different libraries. Ways to copy file to another directoy in Python We will discuss different methods to copy file from one destination […]

  • Copy file Python
    12 January

    How to Copy File in Python?

    Python provides us with many modules and functions to perform file operations. In this article, we will discuss different ways to copy file in python. For this, we will use the os module, shutil module, and subprocess module. We will also discuss advantages and disadvantages for each approach as file operations are costly in terms […]

  • Python absolute path
    17 November

    Get Absolute Path in Python

    We often use files to store the outputs of our programs in permanent storage. Generally, we work with relative paths of files in our programs. In this article, we will discuss two ways to get the absolute path to a file in python from its relative pathname. What is an absolute path to a file? […]

  • Python create file if not exists
    06 November

    Create file if not exists in Python

    Creating Files in Python File handling is a handy concept in programming. We can write and read data to files. In Python, to create or open a file, we use the open() function. It creates an object of file handling that can read or write data to files. Ways to create file if not exists […]

  • Python overwrite file
    06 November

    Overwrite file in Python

    File Handling in Python We can read and write content to files in Python. We use the open() function to create files and specify the path and mode for the required file. This creates a file handling object that handles different file operations. Ways to overwrite file in Python To overwrite a file, we need […]

  • Iterate through files in directory in Python
    30 August

    Iterate through files in directory in python

    A directory, as its name implies, is a place where sub-directories are created and files are stored. A directory with no parent is referred to as the root directory which is usually the main directory. This tutorial demonstrates the different ways available to iterate through files in directory in Python. Python provides the os module […]

  • Write a list to a file in Python
    12 June

    Write a list to a file in python

    Python allows us to work with different data structures and write them to an external file. In this tutorial, we will learn how to write a list to a file in Python. If you want write list to CSV file, you can refer write list to CSV in Python. Using the write() function to write […]

  • Get filename from path in Python
    21 May

    Get filename from Path in Python

    There are different ways to define the path of the file. In Windows, the path separator for a file can be either a backslash or a forward slash. The ntpath module of Python will work on all platforms for all paths. The forwardslash / is used for UNIX and MacOS operating system and backslash \ […]

  • Python read text file line by line
    13 May

    Read text file line by line in Python

    Learn about how to read text file line by line in Python.