Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Trying to batch delete line 3 from many .cvs files  (Read 3449 times)

0 Members and 1 Guest are viewing this topic.

SJK_Daily

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    Trying to batch delete line 3 from many .cvs files
    « on: September 14, 2019, 12:27:42 PM »
    We receive from our clients, thousands of Excel.csv files. Because of the the processes we run them through we need to open each file and manually delete line 3 from each file. It is very time intensive. What we do after we delete the 3rd line we resave the file in the same folder with a 2_ prefix to the file name. Is there any way to batch process these files to do this automatically? Appreciate any help anyone can give me. Thanks, SJK

    nil

    • Global Moderator


    • Intermediate
    • Thanked: 15
      • Experience: Experienced
      • OS: Linux variant
      Re: Trying to batch delete line 3 from many .cvs files
      « Reply #1 on: September 14, 2019, 01:18:29 PM »
      You can certainly accomplish this with many different batch processing tools. Personally, I would recommend Python.

      This is a very similar question to yours, with example code. The only change you would need to make, is to have the program write to a different filename, rather than the original.

      https://stackoverflow.com/questions/4710067/using-python-for-deleting-a-specific-line-in-a-file

      I hope this information helps.
      Do not communicate by sharing memory; instead, share memory by communicating.

      --Effective Go

      Salmon Trout

      • Guest
      Re: Trying to batch delete line 3 from many .cvs files
      « Reply #2 on: September 15, 2019, 01:53:15 AM »
      ......

      SJK_Daily

        Topic Starter


        Newbie

        • Experience: Beginner
        • OS: Unknown
        Re: Trying to batch delete line 3 from many .cvs files
        « Reply #3 on: September 15, 2019, 03:12:57 PM »
        I'm sorry, I've never made one of these batch files before and I don't understand the steps either. I'd need the instructions dumbed down quite a bit. Thanks for any help that anyone is willing to offer.

        nil

        • Global Moderator


        • Intermediate
        • Thanked: 15
          • Experience: Experienced
          • OS: Linux variant
          Re: Trying to batch delete line 3 from many .cvs files
          « Reply #4 on: September 15, 2019, 04:03:30 PM »
          For starters you can download Python from the Windows Store. (I'm assuming you're using Windows 10?)

          https://www.microsoft.com/en-us/p/python-37/9nj46sx7x90p?activetab=pivot:overviewtab
          Do not communicate by sharing memory; instead, share memory by communicating.

          --Effective Go