-1

I'm trying to make a parser in python, and what this will do will convert csv into an excel document (xls), is there a way you can format a csv in a python script to a certain excel layout? I'm finding this very difficult and don't know where to start

4

2 Answers 2

1

Welcome to StackOverflow Shaneyg8! Since this is your first post I figure I'd add a few notes about the site while answering your question.

First off:

Python CSV Module will help you with the CSV part. You can easily read a CSV and perform operations on each row like so:

>>> import csv
>>> with open('eggs.csv', 'rb') as csvfile:
...     spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
...     for row in spamreader:
...         #Do Stuff!

Second, check out the excellent resource commented by Steven Kay and choose the one whose documentation makes the most sense to you. I'd probably start with openpyxl since it's recommended by the list. Though choosing the right library will be up to your needs and which formats you plan to support and handle with your program.

Last, when you post on Stack Overflow you should let us know what you've tried so far. Did you google your question first? Did you look up csv/excel libraries before asking? Did you try looking up "python convert csv to xlsx"? These are things that can answer your question faster than any of us can, and once you put in that effort to try, if you find yourself lost or wondering how to use feature X, then come t the site, let us know about your issue, and ask the specific question for clarification.

The more information you give us about what you tried, the more information we can give back to you and future viewers of your question.

In your case, you may want to look at the two questions that are related/similar to your question here:

Python convert csv to xlsx

https://stackoverflow.com/questions/3504604/recommend-a-python-library-to-read-excel-xls-files

Sign up to request clarification or add additional context in comments.

Comments

0

I believe this is a duplicate of Recommend a Python library to read Excel XLS files, but I will answer to give you the directions.

As commented by @EdgeCaseBerg, you can use CSV File Reading and Writing along with xlrd to achieve what you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.