Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
As a Customer What would do to keep your ERP Implementation intact
Proactively define Business Process-- Take the Project Ownership
50%
Handover everything to System Integrator from drawing BP till implementation of ERP
17%
Hire more inhouse skilled & capable IT Resource to work directly with SI
33%
Rely on SI Architects/Consultants
0%
Total votes: 12

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 1st April 2021, 06:43
jojovalenton jojovalenton is offline
Senior Member
 
Join Date: Aug 2007
Posts: 230
jojovalenton is on a distinguished road
Baan: InforLN FP7 - DB: SQL Server 2008 R2 - OS: Window Server 2008 R2
csv file columns
Baan: Infor ERP 10.1 (FP7)
C/S: Both

hi,
my session is set to use 2 csv file but how can i identify that the users prepared 3 columns or 9 columns csv file? i planned to use pos() but the argument is long.
thanks,
jojo
Reply With Quote
Sponsored Links
  #2  
Old 1st April 2021, 13:01
vahdani's Avatar
vahdani vahdani is offline
Guru
 
Join Date: Aug 2002
Location: Cologne, Germany
Posts: 471
vahdani is on a distinguished road
Baan: all - DB: all - OS: Unix / Win2K
hi,

I think the function str.split() is exactly what you are looking for.
But according to my help file this function is only available from TIV level 2340.
And the function is not mentioned in BaanERP Programmer's Manual here on Baanboard!
So I am not sure if you can use it
Here my test script:
Code:
	domain	tcmcs.str132m	csv.record

		string		csv.columns(1, 1) based
		long		columns.count

function main()
{
	csv.record = "col-1;col-2;col-3;col-4;col-5;col-6;col-7;col-8;col-9"

	columns.count = str.split(csv.record,	|CSV record in
				";",		|Separator
				32,		|Max number of columns
				csv.columns)	|columns

	columns.count = columns.count

}
__________________
May the force be with you!
Reply With Quote
  #3  
Old 1st April 2021, 13:43
jojovalenton jojovalenton is offline
Senior Member
 
Join Date: Aug 2007
Posts: 230
jojovalenton is on a distinguished road
Baan: InforLN FP7 - DB: SQL Server 2008 R2 - OS: Window Server 2008 R2
hi,
thanks for the reply. our tiv is only 1755. i'll try find other way, way too small.
regards,
jojo
Reply With Quote
  #4  
Old 1st April 2021, 14:27
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,574
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Can you use str.scan? The way we used it was pretty much a fixed value, but we did have a few sessions where they could send like 16 or 17 values. It has it limitations but if you knew you were always getting between 3 and 9 values it might work.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #5  
Old 1st April 2021, 17:23
vahdani's Avatar
vahdani vahdani is offline
Guru
 
Join Date: Aug 2002
Location: Cologne, Germany
Posts: 471
vahdani is on a distinguished road
Baan: all - DB: all - OS: Unix / Win2K
Hi,

Mark is right! And one can find this function in Baanboard here: string.scan()

Here my test script. And it works and by me gives ield.count = 9 as expected

... and happy easter holidays everyone
Code:
|******************************************************************************
|* tczzzcsv-cols  0  VRC 107C 0  dev1
|* Count CSV-Columns
|* hova
|* 01.04.21 [12:20]
|******************************************************************************
|* Script Type: 0
|******************************************************************************
|* my session is set to use 2 csv file but how can
|* that the users prepared 3 columns or 9 columns c
|* i planned to use pos() but the argument is long.

|string.scan() function is older TIV compatible!

	domain	tcmcs.str132m	csv.record
	
		string		format.string(100)

		long		field.count
		string		c1(30)
		string		c2(30)
		string		c3(30)
		string		c4(30)
		string		c5(30)
		string		c6(30)
		string		c7(30)
		string		c8(30)
		string		c9(30)
		string		c10(30)

function main()
{
	csv.record = "col-1;col-2;col-3;col-4;col-5;col-6;col-7;col-8;col-9"
	format.string = "%s;%s;%s;%s;%s;%s;%s;%s;%s;%s" 

	field.count = string.scan(
				csv.record,	|CSV record in
				format.string,	|Format
				c1,c2,c3,c4,c5,c6,c7,c8,c9,c10)

	field.count = field.count
}
                                         
}
__________________
May the force be with you!
Reply With Quote
  #6  
Old 6th April 2021, 18:42
BaaNovva's Avatar
BaaNovva BaaNovva is offline
Member
 
Join Date: Mar 2003
Location: Bangalore
Posts: 54
BaaNovva is on a distinguished road
Baan: BaanIV, BaanV - DB: Oracle,Sybase - OS: Win2K
Quote:
Originally Posted by jojovalenton View Post
hi,
my session is set to use 2 csv file but how can i identify that the users prepared 3 columns or 9 columns csv file? i planned to use pos() but the argument is long.
thanks,
jojo
Use a string.scan with 9 variables. If the variables after first 3 are blank then its just 3 columns, otherwise 9. But this method does not guarantee because a 9 column csv file may have first 3 columns filled and rest blank causing ambiguity. You have to determine this by counting the actual delimiters in the first file line. I feel the best method is to run a simple repeat-until loop until the predetermined length of the first trimmed file line. If there are just 3 delimiters, then its only 3 column csv file, otherwise 9. This can give you a definite result.
Reply With Quote
  #7  
Old 6th April 2021, 20:34
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,574
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Hmmm - I think I see what you are saying, but it depends on how the CSV file is created and how flexible you want to make the code. What I did was use a combination of count and variables to make sure I processed it right. So to me this could work for the original request.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #8  
Old 7th April 2021, 09:26
günther günther is offline
Guru
 
Join Date: Jan 2002
Location: Ehingen, Germany
Posts: 621
günther is on a distinguished road
Baan: Baan IVc4, Infor LN 10.6 - DB: Informix, MS-SQL - OS: HP-UX, Windows
Hi,

I would suggest to create a real scanner function that parses a CSV file as specified. All those simple tries will fail if the data contains double quotes, single quotes, semicolons or newlines. So I would loop over the buffer (just read line) character by character and use a simple state machine.

Regards
Günther
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Functions Not Supported in LNUI Arlina Tools Development 7 30th October 2020 07:45
Programming Question mr_suleyman Tools Development 37 11th November 2016 08:14
Undocumented Functions & Variables george7a Tools Development 81 30th September 2015 11:35
Return value -2 on seq.open mmtmalone Tools Development 2 8th January 2014 22:03
bshell received SIGTERM manojsharma Tools Development 11 5th June 2008 09:22


All times are GMT +2. The time now is 15:05.


©2001-2021 - Baanboard.com - Baanforums.com