r/pythonhelp • u/RealDominiqueWilkins • Oct 12 '21
Unable to get past first bit of Jeopardy! parser
Hello,
Relatively new to programming in general and very new to Python. I've been working with this Jeopardy parser to parse a bunch of html files into CSVs. I want to make my own Jeopardy clue database for both Python/DB practice as well as Jeopardy practice. It's a win-win!
Prior to this, I was able to use the download script to successfully download ~8000 html files. I have them stored in a folder called "j-archive archive" which is what the parser script is referencing.
However, when I run the parser, all it does is print "Using 8 threads" and then brings up a new command line, and nothing seems to happen in my folders - no CSVs, no nothing. Seems like it just stopping here. How can I move forward? I have tried a few things and was able to move past this point to some extent, but then it tells me that 'main' isn't defined.
from __future__ import print_function
from bs4 import BeautifulSoup
import time
import lxml
import sys
import os
import re
import csv
import progressbar
import concurrent.futures as futures
# Break up CSVs into seasons
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
SITE_FOLDER = os.path.join(CURRENT_DIR, "j-archive archive")
SAVE_FOLDER = os.path.join(CURRENT_DIR, "j-archive-csv")
NUM_THREADS = 2
try:
import multiprocessing
NUM_THREADS = multiprocessing.cpu_count() * 2
print('Using {} threads'.format(NUM_THREADS))
except (ImportError, NotImplementedError):
passFor more context, I believe this was written in Python 2 but I'm running 3.
I really appreciate any help. Happy to provide more details.
1
u/skellious Oct 12 '21
EDIT: never mind I realised you are trying to adapt someone else's code but only posted a tiny snippet of it here for some reason.
why is your code using a try-except block? You generally want to know if those things are having errors.
As for what is going wrong, at the moment all you are doing is importing a bunch of libraries, setting some variables, setting NUM_THREADS AGAIN for some reason and then printing how many threads you are using.
Your program isn't actually DOING anything, because you haven't TOLD IT TO DO ANYTHING.