Hi,
I am trying to load data from a text file, but text file has LF characters randomly in many places within the text.
TI is treating those LF characters as line breaks, although there should not be line breaks in those places.
I need TI avoid those LF characters. How can achive this? Any ideas?
Thanks in advance for all replies...
How To Avoid LF in source file
- qml
- MVP
- Posts: 1096
- Joined: Mon Feb 01, 2010 1:01 pm
- OLAP Product: TM1 / Planning Analytics
- Version: 2.0.9 and all previous
- Excel Version: 2007 - 2016
- Location: London, UK, Europe
Re: How To Avoid LF in source file
I think you'll have to do some sort of pre-processing of the file to remove the unwanted LF characters. You can do it directly in TI (if you have a way of recognising where the genuine new lines should be - e.g. any LF within a string enclosed in double quotes would be a candidate for removal), but it is way simpler and more elegant to write an external script (e.g. Perl or Python) to deal with the problem before you feed fixed files to TI.
As far as I know there is no way to tell TI which character is used as record separator - most typical newline characters (\r, \f, \n and some combinations thereof) will be recognised as the end of a data record.
As far as I know there is no way to tell TI which character is used as record separator - most typical newline characters (\r, \f, \n and some combinations thereof) will be recognised as the end of a data record.
Kamil Arendt
- macsir
- MVP
- Posts: 785
- Joined: Wed May 30, 2012 6:50 am
- OLAP Product: TM1
- Version: PAL 2.0.9
- Excel Version: Office 365
- Contact:
Re: How To Avoid LF in source file
Yes, Perl can deal with these characters pretty easy.
-
- Posts: 17
- Joined: Thu Feb 20, 2014 8:42 am
- OLAP Product: TM1
- Version: PA 2.0.9
- Excel Version: 2016
- Location: Russia, Saint-Petersburg
Re: How To Avoid LF in source file
Try this:
And Perl has some problems with LF on Windows:
The ultimate guide to Windows and Unix file line ending conversion in Perl https://www.perl.com/article/53/2013/12 ... n-in-Perl/
Code: Select all
powershell.exe -Command "(Get-Content -Path 'C:\Temp\Data File with random LF.csv' -Raw) -replace '([^\r])\n', '' | Set-Content -Path 'C:\Temp\Data File without random LF.csv'"
The ultimate guide to Windows and Unix file line ending conversion in Perl https://www.perl.com/article/53/2013/12 ... n-in-Perl/