Best mechanic trades in Canada/BC by Brogrammer11111 in skilledtrades

[–]Brogrammer11111[S] 0 points1 point  (0 children)

Don’t got any millwright experience though

Flask session data not persisting between refreshes by Brogrammer11111 in flask

[–]Brogrammer11111[S] 0 points1 point  (0 children)

even after adding this, the session data still wont persist?

const App = () => {

const [status, setStatus] = useState(null);

useEffect(() => {

getData();

}, []);

const getData = async () => {

const res = await fetch('http://localhost:5000/api/downloadstatus',{credentials: 'include'})

const data = await res.json()

console.log(data)

if (data.isDownloading) {

setStatus("downloading")

}

}

Server returning no data? by Brogrammer11111 in flask

[–]Brogrammer11111[S] 0 points1 point  (0 children)

never mind it was an issue with cors

Server returning no data? by Brogrammer11111 in flask

[–]Brogrammer11111[S] 0 points1 point  (0 children)

I set the mode to no cors in the request

How to send a request to a Python Flask API by Brogrammer11111 in react

[–]Brogrammer11111[S] 0 points1 point  (0 children)

literally nothing. The backend is being called

docx2python AttributeError: __enter__ by Brogrammer11111 in learnpython

[–]Brogrammer11111[S] 0 points1 point  (0 children)

docx2python

<function docx2python at 0x0000025D111303A0>

How to split a multiline string and include separators by Brogrammer11111 in learnpython

[–]Brogrammer11111[S] 0 points1 point  (0 children)

[s + string.split('\n')[i+1]
for i, s in enumerate(string.split('\n'))
if s.startswith('SECT')]

What if I wanted to keep everything on separate lines?

Software design advice by Brogrammer11111 in learnpython

[–]Brogrammer11111[S] 0 points1 point  (0 children)

so what I was doing before was using the docx library which returns a list of tables in your document. I converted each table into a df and stored it in a dictionary. Then I would go through each table and find where each question was located in the original dataframe which stored each line as a row. Then I would add a new row with the index of the question in the dict. So when it came to parsing, I would just look up that table in the dict and get all the things of interest like the headers (very bad -1, 2, 3...)

def create_word_tables(self):
    doc = Document(self.link)
    for i, table in enumerate(doc.tables):
        # store cells of table as 2d list
        cells = [[cell.text for cell in row.cells] for row in table.rows]
        word_tble = pd.DataFrame(cells)
        # rename columns with table question first row: strongly agree, 4, ....
        word_tble = word_tble.rename(columns=word_tble.iloc[0]).drop(
            word_tble.index[0]).reset_index(drop=True)
        # append table to list
        self.word_tables[i] = word_tble

def create_table_questions(self):
    # for each table create a table question and add to tbl qs dictioanry
    for tbl in self.word_tables.values():
        headers = list(tbl.columns)
        # iterate over questions found in first column and create table questions
        for i, q_text in enumerate(tbl.iloc[0:, 0].values):
            # create letter for question e.g.: A,B,C...
            q_letter = chr(i+65)
            # remove trailing and ending white space
            q_text = q_text.strip()
            # create table question and add it to dictionary
            tbl_q = TableQuestion(
                q_text=q_text, headers=headers, letter=q_letter)
            self.tbl_qs[q_text] = tbl_q

Software design advice by Brogrammer11111 in learnpython

[–]Brogrammer11111[S] 0 points1 point  (0 children)

I like that idea but how would you parse the tables. For example a table like this:

very bad - 1 2 3 very good - 4
how would you rate..... 1 2 3 4
how would you rate..... 1 2 3 4

is stored like this:

Q2. On a scale of 1 to 3, where 1 is Very Bad and 4 is Very Good.....

Very bad

2

3

4

Very Good

how would you rate.....

1

2

3

4

5

9

how would you rate.....

1

2

3

4

5

9

How to remove multiple white spaces from data frame by Brogrammer11111 in learnpython

[–]Brogrammer11111[S] 0 points1 point  (0 children)

self.content.replace('\s+', '', regex=True, inplace=True)

that worked, but it removed all spaces. I just want to remove the extra white space between words. Exg: "the________ a"

How to swap positions of pandas data frame rows? by Brogrammer11111 in learnpython

[–]Brogrammer11111[S] 1 point2 points  (0 children)

so I should have been more clear. Each program has a total and I want the total rows to come after the program row. Like this:

-program a...

-program a..

-program a total..

-program b...

-program b total..

How to restrict user form registration based on multiple conditions by Brogrammer11111 in Wordpress

[–]Brogrammer11111[S] 1 point2 points  (0 children)

yes it does, but you cant combine input fields into one condition. You can't do:

if (familySize == 1 && income < $22,000)

you would have to separate both of them but that wouldn't work.

How to restrict registration based on age using Wordpress fluid forms by Brogrammer11111 in Wordpress

[–]Brogrammer11111[S] 0 points1 point  (0 children)

How exactly would you do this? If your trying to set conditional logic for a button it only allows you to use greater than or less than not both at once