Im trying to convert my .txt file into .xlsx file. I tried few options using openpyxl & xlsxwriter modules, but i was not able to get intended results. My text file is as below:
Text file
I need to convert it in Excel which look like this:
Excel file
Problem is, with the solutions i got till now i could only able to convert all the data in text in Excel, but i need few lines to chopped in between & transposed it to first row. Please help me, as i have to deal with more text to excel convertions manually.
Thanks in advance! :)
Related
hoping someone can help with this - please go easy I'm new to python - what I'm trying to do is download data from tableau as a CSV (which I have done) and then read that csv file using python - the problem I'm having is that no matter what method I try and use to read the file (csv, pandas, etc) all of the data from the csv is in the first 'cell' (col1 row1) and has question marks in diamonds in-between every character (these are also present when the csv file is imported into Google sheets or excel) - what am I doing wrong, or what do I need to do to fix this? - thank you in advance
Also when the csv file is opened in something like notepad it looks like a normal csv file
I have large excel files with format .xlsb and .xlsx. I need to read only one sheet from all these files in python. It takes forever to use read_excel on these files. I want to save off that sheet I need as a .csv file and then read it to make it quicker. The only problem is that I have 24 of these excel workbooks and I don't have the time to manually take that sheet for each workbook and save it as .csv. Any suggestions on how I can change the format of just that one sheet?
An .xlsx-file is technically a folder. It is possible to open it as a zip-file and extract the individual sheets. However, I have never attempted to do this using Python, so I do not know how easy it is to do.
The tried to open an excel file in Python, but it contains a filter in the first row (Image 1), it causes an error in Python that it cannot read it. I tried to use skiprow and changing the .xlsx file to .csv, but that filter from the first row sticks. Is there any way I can read the file without manually deleting that row?
In Excel I have many sheets and they are all with filters in the first row, below is the example of these filters
You could create a duplicate of that excel file, remove the filter and then try again.
You can check out this documentation on how to read excel files.
Documentation
Something like this:
pd.read_excel(open('tmp.xlsx'),sheet_name='Sheet1')
This is probably a really dumb question.
I have a dataframe that has a column containing scores of a soccer game (e.g. 1-2). When I save the dataframe using df.to_csv, and open the .csv file in Excel afterwards, the scores are given as date (e.g. 1-2 is now 1st Feb).
I realize this is an issue within Excel probably, since when I open the file in Notepad, the scores are as they should be.
So my question is, how best to handle it? Is there an option in Python where I can save the .csv in such a format that the score isn't converted to a date? Or is it something to be tackled in Excel?
Thanks!
If you save your file as text (.txt) instead of .csv, Excel shouldn't re-format it.
This might go against your specific needs, if .csv is necessary. But if not, you can achieve the same result (in the sense of delimitation and headers) by opening the text file from Excel's File Menu, selecting 'Delimited'.
Then, if in python you are saving your .txt file with a comma delimitation, de-select the 'Tab' option and select 'Comma'..
I am trying to convert a DAT file which has two sheets in it and multiple columns in one sheet. I suspect that it is a binary file as I am not able to open it using a text editor and when I tried to export it into an excel file format using an internal software it showed that the DAT file has two sheets with one sheet containing some header information while the other sheet is in tabular form. I am now trying to convert these DAT files into CSV format using Python because I would like to convert all the files which I am not able to do so using the internal software.
I have tried a few sample codes that I could find here but it doesn't give me the expected results.
df = np.fromfile('test.DAT')
using the code above that somewhat worked, resulting in array forms as below without any header but I expect it to be in a tabular format.
array([6.01347002e-154, 6.01347037e-154, 3.91007023e+097, ...,
0.00000000e+000, 0.00000000e+000, 0.00000000e+000])
I am not sure how to deal with a DAT file that is resulting in 2 sheets when it is exported as an excel file. Any tips or help on this is much appreciated and I hope my question is clear.