2

I intend to create a small app that uses Brython to convert .xlsx files to .csv files. I used Brython so I can write my code in python instead of javascript. However, I cant upload pandas for some reason. Here is my code:

<!DOCTYPE html>


<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Brython Examples</title>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython.js" integrity="sha256-rA89wPrTJJQFWJaZveKW8jpdmC3t5F9rRkPyBjz8G04=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython_stdlib.js" integrity="sha256-Gnrw9tIjrsXcZSCh/wos5Jrpn0bNVNFJuNJI9d71TDs=" crossorigin="anonymous"></script>
</head>


<body onload="brython()">
    <p>Click on the "Choose File" button to upload a file:</p>

    <form action="/action_page.php">
        <input type="file" id="myFile" name="filename" >
    </form>

 <script type="text/python" >
    #importing pandas as pd 
    import pandas as pd 

    # Read and store content 
    # of an excel file 
    read_file = pd.read_excel ("myfile.xlsx") 

    # Write the dataframe object 
    # into csv file 
    read_file.to_csv ("Test.csv", 
                    index = None, 
                    header=True) 
        
    # read csv file and convert 
    # into a dataframe object 
    df = pd.DataFrame(pd.read_csv("Test.csv")) 


</script>

</body>
</html> 

And here is the error that I get from the console in firefox.

this is the error that I get

  • 2
    you can not do anything using pandas in brython because pandas is a binary package written in C while brython only supports using pure python stuff. So you will have to create a library in python yourself – AmaanK Mar 26 '21 at 10:06

1 Answers1

-1

Pyscript at https://pyscript.net/ is out and can help with this issue.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/32049659) – Ethan Jun 19 '22 at 20:47