Michelangiolo commited on
Commit
9221312
·
1 Parent(s): 9c5d588
Files changed (5) hide show
  1. _test.ipynb +77 -0
  2. app.py +29 -0
  3. test-docs/TestA.xlsx +0 -0
  4. test-docs/TestB.xlsx +0 -0
  5. test-docs/new.xlsx +0 -0
_test.ipynb ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 64,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "text/plain": [
11
+ "['工作表1', 'Sheet1']"
12
+ ]
13
+ },
14
+ "execution_count": 64,
15
+ "metadata": {},
16
+ "output_type": "execute_result"
17
+ }
18
+ ],
19
+ "source": [
20
+ "import pandas as pd\n",
21
+ "import numpy as np\n",
22
+ "\n",
23
+ "res = list()\n",
24
+ "\n",
25
+ "plain = pd.ExcelFile('TestA.xlsx')\n",
26
+ "for sheet_name in plain.sheet_names:\n",
27
+ " df1 = pd.read_excel('TestA.xlsx', sheet_name=sheet_name)\n",
28
+ " df2 = pd.read_excel('TestB.xlsx', sheet_name=sheet_name)\n",
29
+ "\n",
30
+ " comparison_values = df1.values == df2.values\n",
31
+ " comparison_values\n",
32
+ "\n",
33
+ " rows,cols=np.where(comparison_values==False)\n",
34
+ "\n",
35
+ " for item in zip(rows,cols):\n",
36
+ " df1.iloc[item[0], item[1]] = '{} --> {}'.format(df1.iloc[item[0], item[1]],df2.iloc[item[0], item[1]])\n",
37
+ " \n",
38
+ " res.append(df1)\n",
39
+ " # df1.to_excel('new.xlsx', sheet_name=sheet_name)\n",
40
+ " \n",
41
+ "\n",
42
+ "with pd.ExcelWriter('new.xlsx') as writer:\n",
43
+ " for index in range(len(res)):\n",
44
+ " res[index].to_excel(writer, sheet_name=plain.sheet_names[index])\n",
45
+ "\n",
46
+ "pd.ExcelFile('new.xlsx').sheet_names"
47
+ ]
48
+ }
49
+ ],
50
+ "metadata": {
51
+ "kernelspec": {
52
+ "display_name": "Python 3.9.0 64-bit",
53
+ "language": "python",
54
+ "name": "python3"
55
+ },
56
+ "language_info": {
57
+ "codemirror_mode": {
58
+ "name": "ipython",
59
+ "version": 3
60
+ },
61
+ "file_extension": ".py",
62
+ "mimetype": "text/x-python",
63
+ "name": "python",
64
+ "nbconvert_exporter": "python",
65
+ "pygments_lexer": "ipython3",
66
+ "version": "3.9.0"
67
+ },
68
+ "orig_nbformat": 4,
69
+ "vscode": {
70
+ "interpreter": {
71
+ "hash": "fdf377d643bc1cb065454f0ad2ceac75d834452ecf289e7ba92c6b3f59a7cee1"
72
+ }
73
+ }
74
+ },
75
+ "nbformat": 4,
76
+ "nbformat_minor": 2
77
+ }
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gensim import models
3
+
4
+ import pandas as pd
5
+ import numpy as np
6
+
7
+ #multiple inputs are passed as arguments for the same function greet
8
+ def greet(file1, file2):
9
+ res = list()
10
+
11
+ plain = pd.ExcelFile(file1)
12
+ for sheet_name in plain.sheet_names:
13
+ df1 = pd.read_excel(file1, sheet_name=sheet_name)
14
+ df2 = pd.read_excel(file2, sheet_name=sheet_name)
15
+ comparison_values = df1.values == df2.values
16
+ rows,cols=np.where(comparison_values==False)
17
+ for item in zip(rows,cols):
18
+ df1.iloc[item[0], item[1]] = '{} --> {}'.format(df1.iloc[item[0], item[1]],df2.iloc[item[0], item[1]])
19
+ res.append(df1)
20
+
21
+ with pd.ExcelWriter('new.xlsx') as writer:
22
+ for index in range(len(res)):
23
+ res[index].to_excel(writer, sheet_name=plain.sheet_names[index])
24
+
25
+ return 'new.xlsx'
26
+
27
+ # iface = gr.Interface(fn=greet, inputs=["file", "file", gr.inputs.Textbox(placeholder="Enter Question here...")], outputs="text")
28
+ iface = gr.Interface(fn=greet, inputs=['file', 'file'], outputs="file")
29
+ iface.launch(share=True)
test-docs/TestA.xlsx ADDED
Binary file (10.6 kB). View file
 
test-docs/TestB.xlsx ADDED
Binary file (10.7 kB). View file
 
test-docs/new.xlsx ADDED
Binary file (7.44 kB). View file