Split function issue
Hello,
Actually I am stuck with a small problem..
I have a text file with records in the following pattern:
Name:John
Age:22
Course:BTech
Phone:1234
and similarly many records..
Now what I want is:
Enter the name you want the records of: John
Now after entering the name, my code should show all the details related to john only....
I tried with split(":") but not getting things correctly...How to restrict it to john records only...and how to reach to that name entered by the user...
Any help will be appreciated..
Thanking in advance
Abhi.
If this is just a simple school exercise, then just read every four lines into single a record object, parse out the name, then skip the record if it's not the name you want.
On the other hand, if you're designing a large (commercial?) application, with tens or hundreds of thousands of records, you should use a database rather than a flat file. Yes, more code is required, but a simple flat file won't perform well when you reach huge record counts.
Similar Messages
-
Split Function unable to parse string correctly
Hi,
I'm using split function to split string into multiple rows using comma "," as delimiter. In a string I have following values which are not parsed correctly as they have comma inside the values.
American Dawn, Inc.
Battalian USA, Inc.
Fria USA, Inc.
Lazer, Inc.
Mexilink Inc.
Is there any other approach to fix this issue?
Here is the split function Im using:
CREATE Function [dbo].[fnSplit] (
@List varchar(MAX),
@Delimiter char(1)
Returns @Temp1 Table (
ItemId int Identity(1, 1) NOT NULL PRIMARY KEY ,
Item varchar(MAX) NULL
As
Begin
Declare @item varchar(MAX),
@iPos int
Set @Delimiter = ISNULL(@Delimiter, ';' )
Set @List = RTrim(LTrim(@List))
-- check for final delimiter
If Right( @List, 1 ) <> @Delimiter -- append final
delimiter
Select @List = @List + @Delimiter -- get position of
first element
Select @iPos = Charindex( @Delimiter, @List, 1 )
While @iPos > 0
Begin
-- get item
Select @item = LTrim( RTrim( Substring( @List, 1, @iPos
-1 ) ) )
If @@ERROR <> 0 Break -- remove item form list
Select @List = Substring( @List, @iPos + 1, Len(@List)
- @iPos + 1 )
If @@ERROR <> 0 Break -- insert item
Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break
-- get position pf next item
Select @iPos = Charindex( @Delimiter, @List, 1 )
If @@ERROR <> 0 Break
End
Return
End
Another user in this forum posted a split function that
he wrote:
CREATE FUNCTION dbo.splitter(@string VARCHAR(MAX), @delim CHAR(1))
RETURNS @result TABLE (id INT IDENTITY, value VARCHAR(MAX))
AS
BEGIN
WHILE CHARINDEX(@delim,@string) > 0
BEGIN
INSERT INTO @result (value) VALUES (LEFT(@string,CHARINDEX(@delim,@string)-1))
SET @string = RIGHT(@string,LEN(@string)-CHARINDEX(@delim,@string))
END
INSERT INTO @result (value) VALUES (@string)
RETURN
END
GO
Both of them are unable to parse above values incorrectly.
FYI: String is made of values that are selected
by user in SSRS report. I think SSRS when combine values , put comma "," between multiple values.
Any help or guidance would be appreciated.
ZKduplicate of
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/820ac53c-ce25-4cc7-b828-5875a21d459d/split-function-unable-to-parse-string-correctly-in-ssrs-report?forum=sqlreportingservices
please dont cross post
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Order split functionality with PP-PI
Hello Forum,
I am not sure whether we can use the order split functionality with process orders . I had implemented it earlier for a client with discrete MFG production type but not aware whether we can do so in process industry (couldn't find the provision to do so in process order operation overview screen function menu path).
Cheers
KaushikHi Kaushik,
Yes your right.
Order split functionality is only applicable for Discrete manfg not for PI industry this is major difference between PI & DM.But you can achieve this at the time of process order confirmation.
Example :-In the Goods Movement Overview of Process Order confirmation FG material is done Auto GR. This FG material Quantity needs to be splitted. Push button "Split" is provided in the bottom of the Goods Movement Overview screen of Process Order Confirmaton.
Say FG quantity = 25 KG which is to be confirmed. Client wants to split the FG quantity into 1 KG wise, for this he needs to split into 25 times.
You can implement this by using below work order
Please use the WORKORDER_GOODSMVT for splitting the GR in Confirmation
This u can implement in PI.Also check Mr.Paulo reply that could be one possibility.
check & revert.
TnX -
Problem in using Split function
Hello,
I have a problem using the Split function and I can't find any solution in internet.
I'm trying to make a list of int but it seems that the Split function doesn't work.
Can you help me please ?
Here is my code :
public class Dessin
List<Forme> dessin = new List<Forme>();
public void Ajouter(Forme forme)
dessin.Add(forme);
public void Lecture()
StreamReader monStreamReader = new StreamReader("ExempleTout.csv");
int ligne = int.Parse(monStreamReader.ReadLine());
while (ligne != null)
int[] temp = ligne.Split(';'); // Error : 'int' doesn't contain a definition for 'Split'
if (temp[0].Equals("Cercle"))
Cercle cercle1 = new Cercle(temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], temp[7], temp[8]);
ligne = int.Parse(monStreamReader.ReadLine());
foreach (Cercle c in dessin)
Console.WriteLine(c.ToString());
Console.ReadKey();
Console.ReadKey();
monStreamReader.Close();
Best regards,Split is a method of string, not int. You are looking for strings anyway, I don't know why you'd parse to an int to begin with. Try this:
string ligne = monStreamReader.ReadLine();
while (ligne != null)
string[] temp = ligne.Split(';');
if (temp[0].Equals("Cercle"))
Cercle cercle1 = new Cercle(int.Parse(temp[1]), int.Parse(temp[2]), int.Parse(temp[3]), int.Parse(temp[4]), int.Parse(temp[5]), int.Parse(temp[6]), int.Parse(temp[7]), int.Parse(temp[8]));
ligne = monStreamReader.ReadLine();
~~Bonnie DeWitt [C# MVP]
http://geek-goddess-bonnie.blogspot.com -
Function issue of Cross-Reference
Hi,
thanks for your attention on this topic.
there is function issue of Cross-Reference.
when click the Cross-Reference after re-installed the software (adobe Framemaker 7.10), the function is not working. please kindly check the screenshots below:
Error message below:
Please help to check this issue.
software: Adobe Framemaker 7.10
System: windows xp sp3
thanks in advance for your support .
Message was edited by: Lu StevenFire the error log off to the e-mail address indicated in the error message and then contact Adobe Support.
-
Can I use split function in PLD?
Dear Experts,
Can anyone show me if I have this value in a variable F_001 in PLD.
012345-FAB
How can I get the below output? (Taking off the -FAB, by either using a split() function or equivalent)
012345
Much Thanks!
ChinhoHi Chinho,
ok, for example, IF you use add the last 4 Character only in CardCode(-FAB)
F_001 -> CardCode = 012345-FAB
or
F_001 -> CardCode = 1000123456-FAB
or
F_001 -> CardCode = 987456814-ADM
but you need to print the Value of CardCode is before last 4 Character Value .
Output: 012345 or 1000123456 or 987456814
Try this formula in PLD.
Substring(F_001,0,(Length(F_001)-4))
Regards,
Madhan. -
Split Function in Java 1.4
Hi,
I tried the new split function in the Java 1.4 and it works except with some characters like '|' and '[' .
Please review the code below let me now the suggestions.
/***********Program******************/
class SplitCheck
public static void main(String args[])
String aSplit[];
aSplit="ABC|1|a".split("|");
for (int i=0;i<aSplit.length;i++)
System.out.println("String=" + aSplit);
/***********Program******************/
The out program is expected to be like this.
String=ABC
String=1
String=a
But I got it as
String=
String=A
String=B
String=C
String=|
String=1
String=|
String=a
Is there any exception in using the split function.
Waiting for your reply,
ShamI think that was a bad idea to push a regex functionality
into a java.lang.String directly... -
Hi All,
i have a small code :-
String selecteID = "QP|10009";
String radioId []= selectedID.split("|");
int i = 0 ;
System.out.println("radioId[0] ="+radioId);
System.out.println("radioId[1]= "+radioId[++i]);
Its output is
radioId[0]=
radioId[1]=Q
However i wanted the code to return ans as :--
radioId[0]=QP
radioId[1]=10009
Why does the split function does not work for '|' ? Or we cannot use '|' in case of split functions.Personally I prefer split("[|]")coz I hate trying to read RE's full of those dang \\'s
Keith -
The split function doesn't work.
Following function:
var s:String ="test (H) :) (L) (L) :) (H) (H)(H)(H:):) "
var myPattern:RegExp = /\([a-zA-z0-9]\)/g;
trace(s.match(myPattern))
trace(s.split(myPattern))
this is the output:
(H),(L),(L),(H),(H),(H)
test , , , , ,,(H:):)
The split function is deleting all the matches! Why is this happening?The split function works differently with Regular expressions
For example look at this code
var s:String ="test (H) :) (L) (L) :) (H) (H)(H)(H:):) "
var myPattern:RegExp = /\([a-zA-z0-9]\)/g;
trace(s.match(myPattern))
trace(s.split(myPattern))
var myPattern2:RegExp = /(:[)|(pD*]|;[)(*])/g;
trace(s.match(myPattern2))
trace(s.split(myPattern2))
Regular expression pattern 2 will find emoticons and split them into items in the array. For some reason this is not happening in the first regex pattern.
this is the output of the above code (ignore the emoticons):
first pattern: Notice (H) is removed
(H),(L),(L),(H),(H),(H)
test , , , , ,,(H:):)
second pattern: Notice smiley not removed, but split a new array item. This is correct.
test (H) ,:), (L) (L) ,:), (H) (H)(H)(H,:),,:), -
I've noticed that the 'Add edit' aka cut, slice, split function of PP CC no longer adds the edit to the clips selected in the left pane (v1, v2, etc). Instead I have to highlight the actual clips on the timeline before cutting them. This is inefficient and not how Premiere Pro has functioned since I started using it years ago. Is there a workaround for this? I tried locking the tracks I don't want cut and doing an 'Add Edit to all' but there is a half second to second delay using that method which slows down my editing.
In version 7.2.2, the keyboard shortcut works on all targeted tracks when no clips are selected, and on selected clips without regard to targeting. This gives the best of all possible scenarios.
The tool (C) cuts on the clips you apply it to, without regard to targeting. -
Split function failed with '&'
Hi, I'm using the split function to retrieve some values, like this:
String s_id = request.getParameter("id");
String[] id_array=s_id.split("�");
if (id_array != null){
out.println(id_array[0]);
out.println(id_array[1]);
It works almost fine, except when the "id" field contains '&', then I got an error:
java.lang.ArrayIndexOutOfBoundsException: 1
Does anyone have any idea?!
thanks..oops, my code was a bit messed up with the formatting...
try one more time......
if(s_code.equalsIgnoreCase("Participant1")){
while(i3.hasMoreElements()){
final Participant1VO vo = (Participant1VO)i3.nextElement();
out.println("<tr><td><a href=\"insert_code.jsp?id=" + StringUtil.escape(vo.getParticipant1()) + "�" + StringUtil.escape(s_code) + "\">"+ vo.getParticipant1() +" </a></td>" +
"</td><td> <input type='checkbox' name='checked' value= " + vo.getParticipant1() + "> " + "</td></tr>" ); -
Depending on how this discussion board works, I will attempt to update functional issues with this operating system.
9/21/13: Alarm: Setting the alarm is rather akward, the numbers are too rigid, fine, and small. I feel the numbers being larger would be more user friendly.
9/21/13 Calendar: Previous version was superior in certain ways. Shading out a part of the day which you typically don't use (ex: 1am-5:30am) would be great. I feel lost in this update, it does not feel refined. Please allow me to send an appointment through imessage already as well!Tell Apple.
http://www.apple.com/feedback/iphone.html -
Hi All!
Is there any forum related to functional issues in SD and MM.Please do forward me the names if there are any.
Regards
PavanCheck these
http://www.sapfans.com/
http://www.erpfans.com/
http://www.sap.com/community/default.epx?logonStatusCheck=0 (Login required)
Regards,
Vikas Madaan -
Salary Split functionality in R12
Hi there , Does any one used the new feature "Salary Split" functionality in R12
I raised an OSS note , but got a reply that it is the way it works.
-
SGD 4.5 Desktop Functionality Issue
I've come across an odd functionality issue on SGD 4.5. When I start "My Desktop" everything works fine. However if I start a new Full JDS Desktop session on another server, the JDS session doesn't appear to load correctly. New windows automatically open in the upper left corner and can't be moved. If I close both JDS Desktop sessions and open the other system first, then "My Desktop" session doesn't open windows properly. Has anyone come across this? It's not to big of deal right now, but it might become more of an issue when more users start using our SGD instance.
Adam@JRoesler :
The script for installing the users during installation when the users are not created is included some version before the 4.50.907
The SGD version here is only 1 minor version before the latest release.
@aspenhedge:
If I look into the rpm (for Linux install) I don't see a check for a valid shell. It does however try to 'su' into those accounts. I might be wrong in this one.
Can you manually use 'su ttaserv' and 'su ttasys' without any problem? Do these users have a valid home-dir for example.
- Remold
Maybe you are looking for
-
One lockbox for multiple company code
Hi Guru's. Currently we have one company code to many lockbox configured, process is working fine. We are in process of merging two companies. We have a scenario were we have one Lockbox shared between multiple company code, when we process the lockb
-
I need a stepper motor to run a metal sheet
1.i am doing a project in labview .i need a stepper motor to run a metalsheet and i need to interface it with labview.specification of stepper motor is torque: 2n load : 4-5kg arm : 4 2. I am using a vision assistant in labview . If i store the s
-
Is there anywhere I can get a word processor online for my mac? Mine didn't come with appleworks, and I'm just looking for something basic to put on it. I took a look at openoffice.org but I don't think that is right for my system. Thanks!
-
Delivery created without Stock
Hi all, I'm using Function Module SHP_VL10_DELIVERY_CREATE to create a delivery with reference to Sales Order. Everything is working fine, with one exception: The delivery is always created, even when the salesOrder is block without stock confirma
-
Integrate Forms and Reports for Developer Suite 10g
Hi all, One of my client is moving to Developer Suite 10g R2. Currently he is using Version 6i. I've converted the forms into 10g. Only one problem being faced by me is Reports. Our form which used to call the reports was using Run_Product. Now, I've