Python Forum
Very basic help - python & Excel
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Very basic help - python & Excel
#1
Hi All,

I have an excel file with two columns: table and number.

All I want to do is use Python to load an excel file, loop through each row and write the row to a new file as many times as the respective number.

For example the excel file will have (in reality is's much bigger of course):
apples, 1
oranges, 3
grapefruit, 1
banana, 2

The new file will look like this:
apples (1)
oranges (1)
oranges (2)
oranges (3)
grapefruit (1)
bananas (1)
bananas (2)

I've spent 3 hours solid trying to find a way to do this and not even got close to a solution. I've been able to use pandas to read in the data and print it but I can't get my head around how to do the above. I'm now confused to which plugin/tool I should even use.

Going to be honest - I'm teaching myself Python and I am a beginner. I'd usually say I learn really quick but this proving tough. While I appreciate it takes time to learn the basics I do need to get this work done (ideally not manually).

I've got no code of any value to add other printing the two columns from a panda data frame which I'm not sure is even the correct way to go.

Not looking for someone to do my work for me but I could really do with a kind pointer or two to get me going.

As note I'm running Python 3 on Windows 10 installed using Anaconda.

I'm writing my code in Notepad++ and executing in Jupyter QTConsole.

Many thanks
Richard
Reply


Messages In This Thread
Very basic help - python & Excel - by ankey - Sep-17-2018, 03:39 PM
RE: Very basic help - python & Excel - by Larz60+ - Sep-17-2018, 06:50 PM
RE: Very basic help - python & Excel - by ankey - Sep-17-2018, 08:11 PM
RE: Very basic help - python & Excel - by Larz60+ - Sep-17-2018, 08:40 PM
RE: Very basic help - python & Excel - by volcano63 - Sep-17-2018, 08:48 PM
RE: Very basic help - python & Excel - by ankey - Sep-18-2018, 08:16 AM
RE: Very basic help - python & Excel - by seco - Feb-21-2019, 05:00 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020