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;








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.










share|improve this question
























  • 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

















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.










share|improve this question
























  • 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













0












0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












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
);



);













draft saved

draft discarded


















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.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해