mardi 6 août 2019

Invalid syntax on if and else statement

I have a script that I'm trying read and write to a file after some calculations were made on the content of the file. I've set up an if-else block to monitor when to append the list and when to write to the file. The issue here is that I am getting a SyntaxError: invalid syntax on the else block.

The indentation seems right to me but I have yet to see a posting on here that explains how to fix this particular issue.

with open(file_input, 'r') as fin:
    with open(file_output, 'a') as fout:
        writer.csv.writer(fout)
        cid_smiles_list  = []
        if len(cid_smiles_list) < 100:
            for rows in fin:
                split_list = rows.split(",")
                split_list.append(pqq)
                split_list.append(nac)
                cid_smiles_list.append(split_list)

        else len(cid_smiles_list) == 100:
            packaged_list = utils.mp_handler(cid_smiles_list, 
                            pool_size)
            writer.writerow(packaged_list)
            cid_smiles_list.clear()

Aucun commentaire:

Enregistrer un commentaire