• Skip to main content
  • Skip to primary sidebar
  • Home
  • Blog
  • VBA Programming
  • Open-Libre Office
  • Web Stuff
  • Videos
    • VBA Articles
    • LibreOffice And Open Office
  • Excel VBA Glossary
  • About
  • Contact

My Best Stuff Is In The Newsletter

No charge. No spam. Unsubscribe anytime.

Submitting...

Python Create CSV Text File From Tab Delimited

In this tutorial video, I take a file downloaded form a website that is tab delimited and convert it to a comma delimited csv file using a python program that can be called from the command line.

This csv file will be imported into LibreOffice base (Free database software for Mac, PC or Linux) for further processing.

If you program or write macros in a business setting I recommend getting on top of python

This is because when you integrate Python with visual basic for applications vba (Microsoft office) or Basic as used in Open Office or LibreOffice, then you can accomplish most business process automation and reporting tasks that your business unit would ever need.

Python can be used to log into and external website and download any data that that site displays, say to a text file, this text file could then be loaded to an Access database or Excel spreadsheet, all at the click of a single button.

Get notified when new Business Programmer Python blog or video tutorials are created.

Submitting…

Don’t forget to comment below and let me know if this was helpful.

Also feel free to tell me what topics you would like covered in the future.

Filed Under: Python Tagged With: Python

Reader Interactions

Comments

  1. Saurabh says

    15/05/2018 at 21:39

    What’s wrong with this code? Not getting common after every value in the output file.

    ”’
    Created on May 14, 2018

    @author: ssriva112
    ”’
    import os, sys

    def processFile(szPath, szFile):
    os.chdir(szPath)
    lstFile=szFile.split(“.”)

    Fo = open(szFile, “r”, encoding=’latin-1′)
    lstInput=[]

    for oLine in Fo:
    try:
    lstLine = oLine.replace(“\n”, “”).split(“\t”)

    except Exception as e:
    print(e)
    pass

    lstInput.append(lstLine)

    print(szFile +” read”)
    Fo.close()

    fW=open(lstFile[0] + “Output.csv”, “w”, encoding =’ascii’)
    print(“Writing” + lstFile[0] + “Output.csv”)

    for oLine in lstInput:

    szWriteLine = “,”.join(oLine)
    print(oLine)
    fW.write(szWriteLine + “\n”)

    processFile(sys.argv[1], sys.argv[2])

    Reply

Leave a Reply to Saurabh Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Free Training Videos

Make VBA Listbox Work as Database Grid

Image

Ulitmate Excel VBA Advanced Filter Tutorial

Click video and press f for full screen or watch on YouTube

Dynamically Link Images to LibreOffice Base Form

Click video and press f for full screen or watch on YouTube

Create Database with LibreOffice Base

Click video and press f for full screen or watch on YouTube

Create VBA Form In Excel

Click video and press f for full screen or watch on YouTube

Affiliate Disclamer

We hope you love the products we recommend! Just so you know, we may collect a share of sales or other compensation from the links on this page.
Thank you if you use our links, we really appreciate it!

Terms Of Service | Privacy Statement | Copyright © 2024 BusinessProgrammer.com.