millisecond and microsecond information not exported when writing datetime to ExcelIs it possible to force Excel recognize UTF-8 CSV files automatically?Formatting DateTime in Excel XML worksheetPython datetime to string without microsecond componentHow to get float value from excel using openpyxl in python?Date exported is displayed as UTCHow to insert a date time column from excel into datetime field in mySQL?writing data to columns in excel with openpyxl afterWriting data into an Excel spreadsheet - why does it skip every second line?Display the original calculated date in Excel sheet exported to Outlook mailUsing Python to read excel file that contains no headers, modify it then write as another excel file. I get “Cannot parse header or footer” warning
Does academia have a lazy work culture?
A planet illuminated by a black hole?
Anagramming in sixes
Are there any examples of technologies have been lost over time?
Airplanes in static display at Whiteman AFB
Is there anything wrong with Thrawn?
What exactly makes a General Products hull nearly indestructible?
Keyboard shortcut to access contact Quick Search?
Is the "cosmological constant tension" the prime reason that we believe the expansion of the universe is accelerating?
Area of parallelogram = Area of square. Shear transform
Is it legal for private citizens to "impound" e-scooters?
Why are off grid solar setups only 12, 24, 48 VDC?
Memory capability and powers of 2
Why no ";" after "do" in sh loops?
USA: Can a witness take the 5th to avoid perjury?
How may I concisely assign different values to a variable, depending on another variable?
Character is called by their first initial. How do I write it?
What is the meaning of "you has the wind of me"?
What does "a good player" mean in the movie Training day?
How were the LM astronauts supported during the moon landing and ascent? What were the max G's on them during these phases?
Where to place an artificial gland in the human body?
expansion with *.txt in the shell doesn't work if no .txt file exists
How to judge a Ph.D. applicant that arrives "out of thin air"
Why did Saturn V not head straight to the moon?
millisecond and microsecond information not exported when writing datetime to Excel
Is it possible to force Excel recognize UTF-8 CSV files automatically?Formatting DateTime in Excel XML worksheetPython datetime to string without microsecond componentHow to get float value from excel using openpyxl in python?Date exported is displayed as UTCHow to insert a date time column from excel into datetime field in mySQL?writing data to columns in excel with openpyxl afterWriting data into an Excel spreadsheet - why does it skip every second line?Display the original calculated date in Excel sheet exported to Outlook mailUsing Python to read excel file that contains no headers, modify it then write as another excel file. I get “Cannot parse header or footer” warning
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
While export datetime data from a TDMS file to an Excel spreadsheet using openpyxl, millisecond and microsecond information disappears.
Using openpyxl on Python 3.7. The datetime pulled from the TDMS file contains time which includes microseconds, for example here is output from printing the value and style of a variable containing one of these datetime objects:
2018-02-05 14:30:13.290399+00:00
When exported to Excel, the portion after seconds disappears:
2018-02-05 14:30:13
I tried using NamedStyle, but I couldn't find how to define milli- or microseconds using this tool.
from nptdms import TdmsFile
from openpyxl import Workbook
# Writing channel data to Excel spreadsheet
wb = Workbook()
wfilename = 'channel_data.xlsx'
ws1 = wb.active
ws1.title = 'Full Data'
# a is a list of datetime objects pulled from a TDMS file
b = a[0]
print(b)
# output is:
# 2018-02-05 14:30:13.290399+00:00
t = type(b)
print(t)
# output is:
# <class 'datetime.datetime'>
ws1.cell(row=1, column=1).value=b
wfilepath = [somefilepath]
wb.save(wfilepath)
In the resulting Excel file, the cell contains the following:
2018-02-05 14:30:13
This is missing all info after seconds. Can anyone see why this is happening?
EDIT:
I was able to convert to string using the following code:
w = b.strftime('%Y/%m/%d %H:%M:%S:%f')
print(w)
and get the following output in Excel in a 'General' format cell:
2018/02/05 14:30:13:290399
I would still like to be able to export this as datetime instead of having to convert to string.
python excel datetime openpyxl
add a comment |
While export datetime data from a TDMS file to an Excel spreadsheet using openpyxl, millisecond and microsecond information disappears.
Using openpyxl on Python 3.7. The datetime pulled from the TDMS file contains time which includes microseconds, for example here is output from printing the value and style of a variable containing one of these datetime objects:
2018-02-05 14:30:13.290399+00:00
When exported to Excel, the portion after seconds disappears:
2018-02-05 14:30:13
I tried using NamedStyle, but I couldn't find how to define milli- or microseconds using this tool.
from nptdms import TdmsFile
from openpyxl import Workbook
# Writing channel data to Excel spreadsheet
wb = Workbook()
wfilename = 'channel_data.xlsx'
ws1 = wb.active
ws1.title = 'Full Data'
# a is a list of datetime objects pulled from a TDMS file
b = a[0]
print(b)
# output is:
# 2018-02-05 14:30:13.290399+00:00
t = type(b)
print(t)
# output is:
# <class 'datetime.datetime'>
ws1.cell(row=1, column=1).value=b
wfilepath = [somefilepath]
wb.save(wfilepath)
In the resulting Excel file, the cell contains the following:
2018-02-05 14:30:13
This is missing all info after seconds. Can anyone see why this is happening?
EDIT:
I was able to convert to string using the following code:
w = b.strftime('%Y/%m/%d %H:%M:%S:%f')
print(w)
and get the following output in Excel in a 'General' format cell:
2018/02/05 14:30:13:290399
I would still like to be able to export this as datetime instead of having to convert to string.
python excel datetime openpyxl
Bring it in as a string then parse it to the correct format... Otherwise you loose bits..
– Solar Mike
Mar 26 at 17:04
I'd strongly advise against XLSX for sensitive datetimes, the format really isn't suitable and demonstrably error prone but openpyxl does at least allow you to save them iso format.
– Charlie Clark
Mar 26 at 18:04
alright. I will stick with exporting as strings. this is primarily for reporting purposes anyway. I'll export an additional column for time elapsed, also as strings.
– Oxov
Mar 26 at 18:40
add a comment |
While export datetime data from a TDMS file to an Excel spreadsheet using openpyxl, millisecond and microsecond information disappears.
Using openpyxl on Python 3.7. The datetime pulled from the TDMS file contains time which includes microseconds, for example here is output from printing the value and style of a variable containing one of these datetime objects:
2018-02-05 14:30:13.290399+00:00
When exported to Excel, the portion after seconds disappears:
2018-02-05 14:30:13
I tried using NamedStyle, but I couldn't find how to define milli- or microseconds using this tool.
from nptdms import TdmsFile
from openpyxl import Workbook
# Writing channel data to Excel spreadsheet
wb = Workbook()
wfilename = 'channel_data.xlsx'
ws1 = wb.active
ws1.title = 'Full Data'
# a is a list of datetime objects pulled from a TDMS file
b = a[0]
print(b)
# output is:
# 2018-02-05 14:30:13.290399+00:00
t = type(b)
print(t)
# output is:
# <class 'datetime.datetime'>
ws1.cell(row=1, column=1).value=b
wfilepath = [somefilepath]
wb.save(wfilepath)
In the resulting Excel file, the cell contains the following:
2018-02-05 14:30:13
This is missing all info after seconds. Can anyone see why this is happening?
EDIT:
I was able to convert to string using the following code:
w = b.strftime('%Y/%m/%d %H:%M:%S:%f')
print(w)
and get the following output in Excel in a 'General' format cell:
2018/02/05 14:30:13:290399
I would still like to be able to export this as datetime instead of having to convert to string.
python excel datetime openpyxl
While export datetime data from a TDMS file to an Excel spreadsheet using openpyxl, millisecond and microsecond information disappears.
Using openpyxl on Python 3.7. The datetime pulled from the TDMS file contains time which includes microseconds, for example here is output from printing the value and style of a variable containing one of these datetime objects:
2018-02-05 14:30:13.290399+00:00
When exported to Excel, the portion after seconds disappears:
2018-02-05 14:30:13
I tried using NamedStyle, but I couldn't find how to define milli- or microseconds using this tool.
from nptdms import TdmsFile
from openpyxl import Workbook
# Writing channel data to Excel spreadsheet
wb = Workbook()
wfilename = 'channel_data.xlsx'
ws1 = wb.active
ws1.title = 'Full Data'
# a is a list of datetime objects pulled from a TDMS file
b = a[0]
print(b)
# output is:
# 2018-02-05 14:30:13.290399+00:00
t = type(b)
print(t)
# output is:
# <class 'datetime.datetime'>
ws1.cell(row=1, column=1).value=b
wfilepath = [somefilepath]
wb.save(wfilepath)
In the resulting Excel file, the cell contains the following:
2018-02-05 14:30:13
This is missing all info after seconds. Can anyone see why this is happening?
EDIT:
I was able to convert to string using the following code:
w = b.strftime('%Y/%m/%d %H:%M:%S:%f')
print(w)
and get the following output in Excel in a 'General' format cell:
2018/02/05 14:30:13:290399
I would still like to be able to export this as datetime instead of having to convert to string.
python excel datetime openpyxl
python excel datetime openpyxl
edited Mar 26 at 16:53
Oxov
asked Mar 26 at 16:33
OxovOxov
11 bronze badge
11 bronze badge
Bring it in as a string then parse it to the correct format... Otherwise you loose bits..
– Solar Mike
Mar 26 at 17:04
I'd strongly advise against XLSX for sensitive datetimes, the format really isn't suitable and demonstrably error prone but openpyxl does at least allow you to save them iso format.
– Charlie Clark
Mar 26 at 18:04
alright. I will stick with exporting as strings. this is primarily for reporting purposes anyway. I'll export an additional column for time elapsed, also as strings.
– Oxov
Mar 26 at 18:40
add a comment |
Bring it in as a string then parse it to the correct format... Otherwise you loose bits..
– Solar Mike
Mar 26 at 17:04
I'd strongly advise against XLSX for sensitive datetimes, the format really isn't suitable and demonstrably error prone but openpyxl does at least allow you to save them iso format.
– Charlie Clark
Mar 26 at 18:04
alright. I will stick with exporting as strings. this is primarily for reporting purposes anyway. I'll export an additional column for time elapsed, also as strings.
– Oxov
Mar 26 at 18:40
Bring it in as a string then parse it to the correct format... Otherwise you loose bits..
– Solar Mike
Mar 26 at 17:04
Bring it in as a string then parse it to the correct format... Otherwise you loose bits..
– Solar Mike
Mar 26 at 17:04
I'd strongly advise against XLSX for sensitive datetimes, the format really isn't suitable and demonstrably error prone but openpyxl does at least allow you to save them iso format.
– Charlie Clark
Mar 26 at 18:04
I'd strongly advise against XLSX for sensitive datetimes, the format really isn't suitable and demonstrably error prone but openpyxl does at least allow you to save them iso format.
– Charlie Clark
Mar 26 at 18:04
alright. I will stick with exporting as strings. this is primarily for reporting purposes anyway. I'll export an additional column for time elapsed, also as strings.
– Oxov
Mar 26 at 18:40
alright. I will stick with exporting as strings. this is primarily for reporting purposes anyway. I'll export an additional column for time elapsed, also as strings.
– Oxov
Mar 26 at 18:40
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55362068%2fmillisecond-and-microsecond-information-not-exported-when-writing-datetime-to-ex%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55362068%2fmillisecond-and-microsecond-information-not-exported-when-writing-datetime-to-ex%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Bring it in as a string then parse it to the correct format... Otherwise you loose bits..
– Solar Mike
Mar 26 at 17:04
I'd strongly advise against XLSX for sensitive datetimes, the format really isn't suitable and demonstrably error prone but openpyxl does at least allow you to save them iso format.
– Charlie Clark
Mar 26 at 18:04
alright. I will stick with exporting as strings. this is primarily for reporting purposes anyway. I'll export an additional column for time elapsed, also as strings.
– Oxov
Mar 26 at 18:40