मुझे 800,000 कोशिकाओं और 3 एम वर्णों के साथ एक ही समस्या थी जहां एक्सएसएसएफ 1 जीबी ढेर आवंटित करता था!
मैंने xlsx फ़ाइल (जावा कोड से) पढ़ने के लिए openpyxl
और numpy
के साथ पायथन का उपयोग किया और पहले इसे सामान्य टेक्स्ट में परिवर्तित कर दिया। तब मैंने जावा में टेक्स्ट फ़ाइल लोड की। ऐसा लगता है कि यह बड़े उपरांत है, लेकिन यह वास्तव में तेज़ है।
अजगर स्क्रिप्ट लग रहा है
तरह
import openpyxl as px
import numpy as np
# xlsx file is given through command line foo.xlsx
fname = sys.argv[1]
W = px.load_workbook(fname, read_only = True)
p = W.get_sheet_by_name(name = 'Sheet1')
a=[]
# number of rows and columns
m = p.max_row
n = p.max_column
for row in p.iter_rows():
for k in row:
a.append(k.value)
# convert list a to matrix (for example maxRows*maxColumns)
aa= np.resize(a, [m, n])
# output file is also given in the command line foo.txt
oname = sys.argv[2]
print (oname)
file = open(oname,"w")
mm = m-1
for i in range(mm):
for j in range(n):
file.write("%s " %aa[i,j] )
file.write ("\n")
# to prevent extra newline in the text file
for j in range(n):
file.write("%s " %aa[m-1,j])
file.close()
तब मेरे जावा कोड में
, मैं
try {
// `pwd`\python_script foo.xlsx foo.txt
String pythonScript = System.getProperty("user.dir") + "\\exread.py ";
String cmdline = "python " + pythonScript +
workingDirectoryPath + "\\" + fullFileName + " " +
workingDirectoryPath + "\\" + shortFileName + ".txt";
Process p = Runtime.getRuntime().exec(cmdline);
int exitCode = p.waitFor();
if (exitCode != 0) {
throw new IOException("Python command exited with " + exitCode);
}
} catch (IOException e) {
System.out.println(e.getMessage());
} catch (InterruptedException e) {
ReadInfo.append(e.getMessage());
}
उसके बाद लिखा था, आप, foo.txt जो foo.xlsx के समान है मिल जाएगा, लेकिन में पाठ प्रारूप
आप इस कोड को कहां चला रहे हैं? ऐप/वेब सर्वर या स्टैंडअलोन के अंदर? – JSS
मैं इसे टॉमकैट 6.0 – miah
के अंदर चला रहा हूं क्या स्टार्टअप पर टॉमकैट को डिफ़ॉल्ट मेमोरी असाइन की गई है? – JSS