The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Python
 Date format using Set column values

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
belebele Posted - 10/29/2021 : 09:32:35 AM
Hello,

I use a data connector to import excel files containing several sheets. I want to copy two specific cells (B2 and C2 in the example below) of one of the sheets into a new worksheet where I gather all my results. However, when I copy those specific cells into the new worksheet, there is no value displayed "--". The problem comes obviously from the format of the imported cells.

Therefore, I would like to change the format of the imported cells automatically. In order to so, I have implemented a python code in "Set columns values". When my data is a number, it works well as you can see below. In the screenshot, I have simplified the structure of the sheet to make the issue clearer: (t refers to col(D) and tim to col(B)). The cell D1 contains now the value of B2 in the right format.



I am now trying to write another function to do the same with the date format in col(C) but I don't understand well what should I use in this case instead of "float". I have tried the following code but it doesn't work. t refers to col(E) and tim to col(C).



Do you have any suggestion to make this work?

I don't want to change the format of the cell directly in the excel file as I have a huge amounts of excel files to treat. Also, I am using a data connector to import those excel files quickly (they all have the same structure).

Thanks a lot for your help,
Greg
3   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 11/01/2021 : 12:53:01 PM
Left aligned means the column is holding text, not numeric, so you need to first fix how you put values into the worksheet.

CP
belebele Posted - 11/01/2021 : 10:51:01 AM
Thanks James for your reply.

I tried your code but I got the following error:



Maybe the format of my cells are slightly different from the one in your trial? My values (date and numbers) are left-aligned after importing them.
YimingChen Posted - 10/29/2021 : 11:19:04 AM
The date/time system in Origin is based on the astronomical Julian Day, so basically it is just a float number behind each date value. So in coding you simply treat it as number. See the figure below:
https://www.originlab.com/doc/Origin-Help/DateTime-in-Origin#Origin.27s_Mathematical_System_for_Date_and_Time



James

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000