LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remove the last Line-Feed character at the end of Array to Spreadsheet String.vi

Hello everyone,
Does anyone know how I could remove the last Line-Feed character used as a delimiter in the Array To Spreadsheet String function.  I need the Line-Feed character in order to separate out the individual strings fed in by a while loop to fill the rows in a Spreadsheet, but I want to get rid of the last Line-Feed character.  Without that, the next set of data concatenated to the first column using the Concatenate Strings function is being appended at the bottom of the first column, which is not what I would like to have.  I would like to see that the next set of data is contiguous with the first column and basically fills up the columns next to the first one.  Could somebody help?  Would really appreciate, many many thanks.
Carnot.
0 Kudos
Message 1 of 13
(9,298 Views)
Use the "match pattern" function with a "regular expression" input of "[\r\n]*$" (w/o quotes).  This will strip zero or more instances of consecutive carriage returns or line feeds anchored at the end of the string.  The "before substring" output will contain the resulting data string.
Message 2 of 13
(9,293 Views)
Let me see if I understand your question.  You are converting a 1-D array of data to a string using the Array to Spreadsheet String.vi.  You have a second 1-D array of data that you want to write to a second column in the string.  Removing the last EOL character is not going to accomplish this.  I know of two possible solutions depending on your exact needs.  First, you could format your 1-D arrays into the appropriate 2-D array and then convert to spreadsheet string.  This will allow your data to be read into the spreadsheet easily.  Another way would be to transpose your data so that your columns are now rows and you only have one EOL character.  Each time you add data you would have a new row.  You can then transpose this in your spreadsheet program to get the desired output.
 
If you really are just needing to remove the character then use Jim Kring's approach.

Message Edited by John Rich on 08-22-2005 10:30 AM

0 Kudos
Message 3 of 13
(9,286 Views)
Andi if want you mean is appending a column to an already written spreadsheet file, you have to read the existing file as a 2D array with Read From Spreadsheet and then using an Insert into Array, insert your new 1D array into column 1.

Message Edited by Dennis Knutson on 08-22-2005 09:32 AM

0 Kudos
Message 4 of 13
(9,284 Views)
Hey thanks,  but I have multiple Line-Feeds but want to remove the very last one and keep the rest, is there a way to say it's the last one to be picked up to delete?  Cheers.
0 Kudos
Message 5 of 13
(9,278 Views)


@Carnot wrote:
Hey thanks,  but I have multiple Line-Feeds but want to remove the very last one and keep the rest, is there a way to say it's the last one to be picked up to delete?  Cheers.


You can use the regular expression "[\r\n]$" to match the last carriage return OR line feed at the end of the string.  Or you can use "\r$", "\n$", "\r\n$" if you know the specific EOL that you want to match.  Note that we ommitted the "*" which tells the match pattern function that we want zero or more instances of the preceeding pattern.
Message 6 of 13
(9,271 Views)
How is removing the last line feed going to accomplish what you want to do?  When you go to append the next data set it will just put the first character in the second column of the last entry from the first data set and will put the remainder of the data in the first column.  Unless I'm missing your point about what you're trying to accomplish removing that line feed will not be beneficial.
0 Kudos
Message 7 of 13
(9,267 Views)
I think John got that right, I'm just trying your solution here.  But all your input is appreciated.
0 Kudos
Message 8 of 13
(9,266 Views)
Actually I don't think that I was exactly right.  What will happen is that the last number from your first data set and the first number from your second data set will be concatenated together, but it will still be in column one (you're not adding any type of delimiter).
0 Kudos
Message 9 of 13
(9,259 Views)

> Does anyone know how I could remove the last Line-Feed character used as a delimiter in the Array To Spreadsheet String function.

 

Trim Whitespace.vi is the simplest solution. It removes end of lines as well as spaces.

Message 10 of 13
(4,438 Views)