Inexperienced Programming Question
TLDR: What programming language would be useful for taking info in an excel file and producing a text file (that is organized and arranged in a particular way) containing that info? Which would be useful for this problem but also helpful in general? And also, are there any recommended online courses where I could learn it?
I have no real experience coding or anything but have always wanted to learn. Recently at work we've encountered a problem. My boss had created a matlab program in order to take text/numbers from an excel document and transfer them to a text file, but in an organized way.
Say you have something you call "Pancakes" and the cell next to it has the number "3", as in there are three pancakes. I want to be able to create a text file that would read something like this:
NUMBER OF PANCAKES
- Pancakes: 3
We recently have changed around the format of the excel document for a different item, for example "French Toast". I've tried to mess with matlab briefly but was unable to change the program to compensate, and I no longer easily have access to matlab.
I'm seeing this as an opportunity to learn some programming and also fix some stuff at work. So what programming language would be useful for fixing this problem? Which would be useful for this problem, but also helpful in general? And also, are there any recommended online courses where I could learn it?
Thanks for any help, I appreciate it.
Any would work. If you're looking for a simple approach, Python is likely your best bet. If you have questions, feel free to ask. This comment from today has some resources; there should be a ton of resources to learn Python.
I'd also highly recommend Python, it's become my go-to for writing quick scripts and simple tools.
I'd suggest Codecademy to learn the basics, and from there, you'll pretty much just search/read the docs for those little bits of functionality. For example, you're parsing Excel files, and luckily, Python has a built in CSV library! You could search for basic usage of the library, or read the documentation itself. Once you have a bit of experience, you can throw together stuff to make one-off scripts very quickly with Python.
Good luck!
Edit: should also add, aside from simple tools like these, Python lets you do pretty much anything else as well - desktop software, games, even websites (like Tildes), so it's a very good investment of your learning.
Thanks, I did want a program that would help me beyond just this task so python sounds like a great choice
The most important thing is to just start and keep going. People will recommend tons of different things. I personally loved 'automate the boring stuff with python' as a source, the excel chapter will be helpful for you once you understood the basics
Thanks, a few others recommended "Automate..." So clearly I need to check it out
I just wanted to echo that Python is an ideal first language for getting started quickly. You don't have to worry about type juggling, you don't need to go through a complicated setup process, you don't need to learn how to compile a program, you don't need to navigate a command line, it's incredibly flexible, and it can do a lot of useful stuff out of the box. It's also popular enough that there are countless tutorials available to show you how to accomplish a task.
Whenever someone wants to learn about programming on their own, Python is always my first recommendation :)
Great, that post actually reminded me to ask the question. Thanks a lot, I'll give it a shot.
I'd suggest trying out the (free) book Automate the Boring Stuff with Python: https://automatetheboringstuff.com/
It seems to be well-regarded, and it's basically intended as a way to learn programming by applying it to tasks exactly like what you're describing. Chapter 12 is even specifically about working with Excel files.
He also has a video tutorial on udemy and I think there is a 50 percent off thing floating around on reddit for his course. But I think udemy in general always has sales for 10 dollars.
Woah, thanks for the link! I've been meaning to dip my toe into Python and that might just be the resource I need to do it.
Thanks, this was recommended by a few others. Definitely seems like what I'll want once I get the basics down
Oh, it should teach you the basics. It says "Practical programming for total beginners" and "no prior programming experience required".
Python is great. You can find any number of free language classes, but if you're like me and like to learn by doing, just go download Anaconda for Python 3 and lookup Excel tutorials like this one. There's tons of sample code all over the internet, just google anything you don't understand and start changing the code until it does something interesting. Any common package you're likely to need such as
xlrd
will already be bundled with Anaconda, so just ignore any talk about pip or virtual environments until you're more comfortable.Thanks, I'll definitely take a look. I'm also a hands-on person so jumping right might be good
Just bumped into this by chance. Could be useful to you:
https://realpython.com/python-csv/
Since OP is talking about Excel he may be interested in pyexcel if he can't or doesn't want to export the Excel data to csv. I've used it and it's pretty simple. The README.rst file has a lot of useful and simple examples that OP can copy & paste and modify to his needs.
Another option is openpyxl. That’s my go-to module for parsing .xlsx workbooks.
That one is actually more powerful and is the one used by pyexcel as stated here. Pyexcel is just a simplified wrapper around openpyxl, I thought OP may prefer it because he said he's inexperienced.
Thanks! This looks very useful
Yeah I'd imagine I could make any language work, but judging by responses and just to start out, python seems to play the most nicely.
Thanks for breaking down the languages into their practical purposes though, that helps. So far, python definitely seems to be the most useful for me now, both for this task and in general.
Which distros don't come with Python preinstalled?
How complex is this existing program? Does it work well, how much MATLAB expertise can you draw on (from yourself and others).
If it's just about trouble with MATLAB licenses my first thought would be to see if your existing program can run in GNU Octave. It isn't a complete Matlab replacement (some missing functions). But if you're just converting a spreadsheet to text it may well do the job.
I basically have 0 experience with Matlab besides messing around, and the issue is with licenses as the company is a startup with limited resources.
I'll have to look into GNU octave, it sounds interesting
From a least effort perspective switching to Octave could be the way to go, I'd agree that future productivity wise your best bet is Python.
Whenever I hear "text file", "text processing", "text manipulation", I am tempted to answer
Perl
! because that's right where it shines.However, in this case, your need for processing/manipulation seems super basic, so a lot of languages match the need, and I'd answer: any language which has a good reliable library to read Excel files (to save the small pain of exporting to CSV). And since you have no coding experience, I will not try to recommend against the most common given proposition (
Python
) :-)I would highly recommend the book
"Automate the boring stuff with python".
Its available for free under creative commons and is designed to teach complete beginners exactly the things that you are wanting to learn.
I'll definitely have to check it out then, free is always good
Definitely Python - it does really well with file IO and string manipulation. An excel file should be a wrapper for a generic XML file of some kind which should be fairly simply to parse. This should take no more than a few hours and is really an excellent starter project for learning.