![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | can i preprocess text for ssis? as background, i have a conditional split transform in front of several derived columns, the condition is based on what characters appear at position 60 in each line. this was needed because the state changed the file format, but the files are all stored in a shared way, we cant move or change them. there are 440 files of several hundred thousand lines, so inspection is not a possibiltiy, the spec was fine for spelling out the 'switch' characters for most of the files, but we'd like to do kind of a select distinct to show each character at position sixty for each line in each file, so we are sure that the conditional split transform has accounted for all the switch characters, because we suspect that there are other characters in that position that we need to trap, (they dont error, but they dont find a home in the distribution either) but dont want to sort though all the text files to find the unknown character(s) at position sixty. the other thing is related, but on different text files from the unix side of the house, to be able to insert a CRLF at position 1201 in a file that has no line feeds, it just one giant line, so we can chop it into 1200 byte size lines each. i am sick of them telling me to open it in wordpad to fix it, and that gets old fast too. i have no idea how to go about doing these two jobs, but they would really move the rock. thanks very much drew |
| | #2 (permalink) | ||||||||||||
| Guest | Re: can i preprocess text for ssis?
#Get the contents of the file $string=get-content test.txt #Loop here, start with $i=0, and increment by 4. #You'd do perhaps $jump=1200 #And stop and the end. $jump=4 for($i=0;$i -lt $string.length;$i=$i+$jump) { #Get the substring, after moving up #to the current $i position, and getting #the next $jump characters. $cur=$string.substring($i,$jump) #Echo out $cur #Or write to a file, but uncomment #$cur|add-content -path test1.txt } -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: can i preprocess text for ssis? Hal Rottenberg wrote:
Get-Content unixfile.txt | % { $_.Insert(1200, "`n") } | set-content dosfile.txt -- Hal Rottenberg <hal@xxxxxx> Author, TechProsaic (http://halr9000.com) Webmaster, Psi (http://psi-im.org) Co-host, PowerScripting Podcast (http://powerscripting.net) | ||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: can i preprocess text for ssis? Hi In working through this, (after making the changes to 1200 and add-content) i get an error that says [System.Object[]] does not contain a method called substring at 14:26. What is peculiar is that it worked the first time as you wrote it ($jump = 4 writing to the console) but this error materialzed when I set $jump=1200 and wrote it to a file. thanks very much for bearing with me, using it is the only way to learn it! drew "Marco Shaw [MVP]" wrote:
| ||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: can i preprocess text for ssis? drew wrote:
marco DOT shaw AT gmail DOT com | ||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||
| Guest | Re: can i preprocess text for ssis? Marco Shaw [MVP] wrote:
single line. get-content always seems to produce an array, by default. So if you have a single line, get-content is giving you an array object. The array object doesn't have a insert or substring method. You have to specifically cast to a string: [string]$content=get-content my_one_liner_file Then, you have the string methods available for $content. -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| replacing text on multiple text files | chufa72 | VB Script | 13 | 3 Weeks Ago 03:52 PM |
| MVP's, text to speech!!, Can I dictate in other text input program | andy t | Vista General | 0 | 07-15-2008 02:58 PM |
| Howto: Add lines of text from a specific point in a text file.. | Daz | VB Script | 13 | 06-24-2008 10:55 AM |
| SSIS - string variable! | Daniel | .NET General | 0 | 05-15-2008 05:53 AM |
| How do I read a text file and sort text by fixed positions? | Cornelius | PowerShell | 5 | 07-20-2007 06:34 PM |