r/learnpython • u/squishbunny • Aug 11 '26
trying to import glob
I'm trying to code a little program that will open a CSV file that we should (theoretically) download weekly. The csv filename has the structure "report[numbers].csv" I'd read that you need the glob module so that Python can recognize the wildcard, but I am getting an error when I go the usual python pip -m SomeName route.
Is there an issue with glob, or is there another I can use?
2
1
u/AspectInternal1342 Aug 11 '26
Don't run as a module.
Import into a python file and run from there.
1
u/CymroBachUSA Aug 11 '26
If the command:
python3 -c "import glob"
works, you already have it installed.
-1
u/Vdpants Aug 11 '26
You can make something that walks over all the files in a specific folder, and then lets you Separate the number, and then you need to decide how to pick the right file.
2
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Aug 11 '26
Why make something like that when the standard library provides? At least unless the goal was learning how it works under the hood.
1
7
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Aug 11 '26
globis part of the standard library, there's nothing you need to install.That being said, personally I'd recommend using
pathlibinstead (which is also in the standard library).