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
 data merge

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
ulhong84 Posted - 05/09/2023 : 8:40:26 PM
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System:OriginPro 2002 (9.9.0220)

I have 10 individual data and import the data one by one as shown below.
How can I import 10 individual data into one table at once?

And what is the commend to disconnet the sheet?


import originpro as op

f = op.path('e')+r'Samples\python\price.dat'
wks = op.new_sheet()

#Use CSV connector which is the default
#and connector will be removes after import
dc = op.Connector(wks)

#Specify the rows to import
ss = dc.settings()
partial = ss['partial']
partial[op.attrib_key('Use')]='1'
partial['col'] = '2','3'

#import from col 2 to col 3
dc.imp(f)


Thank you~




4   L A T E S T    R E P L I E S    (Newest First)
minimax Posted - 10/24/2023 : 02:11:05 AM
Hi,

Besides calling method_int(), you can also use either of the following ways to remove the connector:

wks = op.new_sheet()
dc = op.Connector(wks,keep_DC=False)

or
dc.imp(csvf)
wks.remove_DC()
minimax Posted - 05/12/2023 : 03:21:53 AM
quote:
The code you let know does not have any equal symbol.


method_int() is mainly used to execute Origin's LabTalk object methods, and it does not require equal sign.

Here its return value is not very helpful, so it is fine not to have equal symbol.

quote:
If there is no way to import separate dat into one book, is there other way such as below?


I suppose there is no python interface to do this yet. (we will check if we could support it later: ORG-27049)

For now you may have to call some LabTalk scripts, like X-Function wAppend:
https://www.originlab.com/doc/X-Function/ref/wAppend

Following is a sample script to merge the imported columns.

import os
import originpro as op

# collect files to be imported
path = os.path.join(op.path('e'), r'Samples\Batch Processing')
csv_files = [os.path.join(path, f) for f in os.listdir(path) if f.endswith('.csv')]

ranges = []
for csvf in csv_files:
    wks = op.new_sheet()
    dc = op.Connector(wks)
    ss = dc.settings()
    partial = ss['partial']
    partial[op.attrib_key('Use')]='1'
    partial['col'] = '2'
    dc.imp(csvf)
    wks.get_book().method_int('dc.remove')
    ranges.append(wks.lt_range())
    
allsheets = '(' + ','.join(ranges) + ')'
op.lt_exec(f'wAppend -r 0 irng:={allsheets} method:=column ow:=[<new>]<new>;')


ulhong84 Posted - 05/11/2023 : 8:11:10 PM
quote:
Originally posted by cpyang

Sorry, we didnt think of adding that to dc class, but you can use the following to remove it


wks.get_book().method_int('dc.remove')


CP



The code you let know does not have any equal symbol.
Could you check it?


I have another question.
If there is no way to import separate dat into one book,is there other way such as below?
When I have 10 book separately, how can I merge these individual data in to one book? The data format in each book is the same format.
cpyang Posted - 05/09/2023 : 9:12:13 PM
Sorry, we didnt think of adding that to dc class, but you can use the following to remove it


wks.get_book().method_int('dc.remove')


CP

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