Django lib to create xls-files over 65k rows? - django

Is there an excel-lib for Django, whom doesn’t put a limit at 65k+ rows?
Or plan B: dirty workaround to make xlwt produce the desired files?

You need to use the new Excel format, xlsx, instead of the old one with xls extension. After Excel 2007 the 65.000 row limit was increased to 1 million rows. Unfortunately, I don't know about Django and I can't suggest any library to produce the new Excel format.

Related

PowerBI Removing top rows by applied steps in PowerBI skips rows of multiple files

I have multiple Excel files in one folder and I loaded the entire folder to PowerBI. The first Excel file is the sample file to PowerBI and I applied some formatting steps to this table of which one of those is to remove the top three rows. PowerBI should now remove the three top rows of all other Excel files in this folder too now. However, I see that of some Excel files it only removes 1 row. Does anybody know what causes this? Thanks in advance.
This is probably caused by inconsistent Excel files. The most common issue that would cause the behavior you describe is hidden rows in Excel, which Power BI will read as data rows. But hey - it's Excel so the users could've done almost anything.
You can edit the Sample File query to point it at the file with issues which might give you more insight.
More generally I would say that is a fragile query design, instead I would try to filter on a column e.g. Remove Empty.
It was caused by the fact that the merging of all Excel files happens before the Top 3 Rows were removed, resulting in the fact that only the first three rows of the total merged table were removed.

Update old excel from New by keeping the formatting with python

I am trying to update old excel file with new one with the data by comparing date in two excel files.
Objective is to update the previous dates columns and add new dates found in new excel into the old excel.
Also copy the formatting from old column into new columns that were added.
What I did, I tried to merge the dataframes from two excels. I still do need help on the logic.
Excel Old File
Excel New File
Please someone help in this
The formatting is kind of worth a separate question.
Here's my approach to the merge that i think you are seeking.
In quick summary we use combine_first()
df_old_excel = pd.read_excel(r'C:\temp\Excel_Old_File.xlsx',header =1)
df_new_excel = pd.read_excel(r'C:\temp\Excel_New_File.xlsx',header =1)
df_old_excel = df_old_excel.set_index('DATE')
df_new_excel.index = df_old_excel.index
df_new_excel.combine_first(df_old_excel)

Read excel column using Python code(in Linux) and get formula values

I have a pandas dataframe that looks like this:
A B C
1 2 =A2+B2
3 4 =A3+B3
I write this to an Excel file using xlsxwriter in Python and convert the data frame to Excel. Now, when I read the Excel from Python, I get 0.0 as the value for C2 and not 3 (=A2+B2). However, if I open Excel manually, the formulas are evaluated and has '3' in 'C2'. So the problem occurs while reading from code.
Is there a way in Python to read Excel columns with formulas as values?
So the problem is while reading from code.
Not really.
The issue is that XlxsWriter doesn't write the value of a formula to an Excel file. From the XlsxWriter FAQ:
Formula results displaying as zero in non-Excel applications
Due to wide range of possible formulas and interdependencies between them XlsxWriter doesn’t, and realistically cannot, calculate the result of a formula when it is written to an XLSX file. Instead, it stores the value 0 as the formula result. It then sets a global flag in the XLSX file to say that all formulas and functions should be recalculated when the file is opened.
This is the method recommended in the Excel documentation and in general it works fine with spreadsheet applications. However, applications that don’t have a facility to calculate formulas, such as Excel Viewer, or several mobile applications, will only display the 0 results.
If required, it is also possible to specify the calculated result of the formula using the optional value parameter in write_formula():
worksheet.write_formula('A1', '=2+2', num_format, 4)
I would save the Excel file as a .csv. Excel should automatically convert all formulae to values. You can then read the .csv into Python with the usual file methods.

How to read and write data in Microsoft excel 2010 in python

Steps what I have done
1.Reading input data from xlsx file
2.calculated week number and total hours done by each department
Need to do:
1.Reading particular row column from another existing xlsx sheet
2.writing total hours for each department in existing xlsx sheet
I am using xlutils but format of xlsx file has been corrupted,which library i should use for this?
According to
http://www.python-excel.org/
, the best library to read/write Excel 2010 files is openpyxl.

Export SAS data to SPSS, date and datetime

I have data inside SAS.
I want to store the datafile to SPSS format (*.sav)
I use the following program:
PROC export Data=SASdataToStoreInSPSS
FILE="Path\Filename_%sysfunc(today(),date9.).sav"
dbms=sav replace;
RUN;
This works great. Except when I open the file in SPSS the dates are strangly formatted.
For example:
156405 08:51:00
Should be
3-Jan-2011 08:51
I can manually change the data formats in SPSS. So the values are correct date values, except they are not automatically formatted in a readable format.
I tried to change the format in SAS before saving to DATETIME20. or DATETIME23.3. But this does not help.
I want this to work without having to open SPSS and run a Syntax there.
The SPSS files that SAS spits out have to be directly mailed to other users of the data.
I think this is either a bug with SAS's export, or an issue with SPSS where some default changed. What's happening is that SAS is storing it as a SPSS Date - but with width 16, which is not long enough to hold the complete datetime. I don't think you can use DBDSOPTS with DBMS=SPSS, so I don't know that there is a good workaround short of importing the file into SPSS.
You could do that automatically, though, using the SPSS Production facility; I've written an import script before and asked SAS to run spssprod with the batch file. That's an irritating workaround, but it might be the easiest, unless SAS Tech Support can help you (and certainly try that - they are usually only a few hours' turnaround for initial contact at least).
SAS mentioned it has to do with the SPSS driver they use. Apparently it is not an easy fix so they forwarded the issue to second-line tech support.
The workaround you will need is split the dates in two columns. One with date and one with time.
data SPSS2;
set SPSS;
date = put(datepart(DatumSPSS), date9.);
time = put(timepart(DatumSPSS), time8.);
run;
Or you can tell the end user how to change the format of the date in SPSS.
For an automated approach, try this .NET app. You need SPSS, but SAS is not required to convert a large collection of SAS files automatically.
Manual Process included code samples or Application Download