简体   繁体   中英

Use Python to find groups of consecutive numbers in excel

SO i embarked on learning python a couple of weeks ago through codecademy and it has been a slow process for me. But unfortunately I'm at a point right now that i need a script to do a specific function for me right now.

I have an excel doc that is a list of ID numbers, example - 72100234 72100235 72100239

There are roughly 50,000 id numbers. I need a script that will do a couple of things for me. - first is to show me how the job is done so i can learn from it - second is its purpose, I need it to go through and find the consecutive numbers and group them together in either a separate file or another tab

Example -

72100234 72100235 72100236

72100239 72100240

I have to find these blocks of numbers so they can be assigned to a specific agency and going through the list manually... yeah, been there, done that, dont want to do it again.

Thanks for any help.

try to divide your problem into different steps.

The first step could be to get familiar with a library to access your excel file. The one i tend to use is "openpyxl". To find out how to get data from an excel file you can use this link: https://openpyxl.readthedocs.io/en/stable/optimized.html . I am new here aswell and i found out that you should first make an affort to try yourself and afterwards people will be very helpful.

After you found out how to get the data from excel to python you could provide some of it. That would make it easier to understand your problem. I hope i could help you a bit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM