Ignore CRLF ("\r\n") in a csv file Programming Software Development by Tommymac501 … (and SQL) can use by replacing the newlines with CRLF's. This is the code I'm using: [CODE… csv.writer(open("clean_data.csv", "wb")) crlf = '\r\n' for row in cr: for col in …row: if crlf in col: #col.replace("\r\n", "… Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by Tommymac501 …'s intact. The second record has an embeded CRLF in one of the fields, and the record …ends at that line CRLF, the third record picks up in the middle… of the field following the CRLF as it's starting point to the end…is to byte-read the file once, replacing and CRLF combinations (chr(13)+chr(10)) with an empty … Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by TrustyTony …? [CODE]D:\Python27>cat Tools\Scripts\crlf.py #! /usr/bin/env python "Replace CRLF with LF in argument files. Print… Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by Tommymac501 This looks to replace the CRLF at the end of a line with a LF, for … to finsh as I've discovered, but it retains the CRLF inside the columns too. Using 'COL.Replace('\r\n', '') doesn… be doing anything either. MSSQL keeps choking on the embedded CRLF's as it tries to import, so I need to… Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by Tommymac501 … get rid of them. The issue is not removing the CRLF's, it's getting Python to read 'past' them and… to the UNIX line-end of 'LF', keeping the CRLF's inside the fields only, so that I 'can' remove… your solution, as it seems the CSV method keeps the CRLF's in the fields and see if it works. Thanks… Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by Beat_Slayer … = csv.writer(open("clean_data.csv", "wb")) crlf = '\r\n' for row in cr: for col in row…: if crlf in col: #col.replace("\r\n", ""… Catch CrLf Characters Programming Software Development by gspeedtech …, I have a situation where data in a field contains CrLf characters. Code has been in place for a couple of…. The question is: Should I add code to catch the CrLf characters at the field level? Should I add code to… uploaded to SQL? Should I modify the upload to catch CrLf characters and possibly correct the data in the upload procedure… Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by Tommymac501 It doesn't error out at all. Since the records are veriable lentgh to begin with, it just lops it off at the embedded CRLF and treats what follows as a new record. Re: Catch CrLf Characters Programming Software Development by codeorder … that will go through the entire database and correct code? CrLf is nothing but a line break, like vbNewLine. See if… this helps to catch the CrLf. [CODE] Dim sTemp As String = "some" & vbNewLine… Re: Catch CrLf Characters Programming Software Development by Huntondoom the Vbnewline or Crlf or what ever does have its number that tells the textbox that is must create a new line but to detect it you must know it Byte or Ascii number to find it Re: Catch CrLf Characters Programming Software Development by gspeedtech Thanks codeorder! I tried your suggestion, but for some reason it does not catch the Crlf. Re: Catch CrLF in a Transaction File Programming Software Development by gspeedtech … file named TransactionFile I need to find CRLF characters in the data and replace the CRLF characters with a space. I am… Catch CrLF in a Transaction File Programming Software Development by gspeedtech … being uploaded to another application that does not accept "crlf". My question is: How can I scrub the TransactionFile… Small Script to convert CRLF to LF Programming Software Development by Satyrn … all sh files in the target directory and then :: Convert CRLF to Unix Style LF echo Converting Line Feed Carriage Returns… Re: export to excel using string builder - maintain tabs/CrLf in data Programming Web Development by rikb53 … named: since it's building html - i looked for the CrLf as "Environment.NewLine" replaced it w/ the html… Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by TrustyTony How about count of '\r'? And .replace('\r','')? Or doing ' '.join(col.split()) replacing white space with one space everywhere? Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by Beat_Slayer And something like: [CODE]newdata = data.replace("\\r\\n", "")[/CODE] Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by TrustyTony About linefeed handling of Python I think it does it's own magic automatically so that everything looks '\n': [QUOTE]os.linesep: The string used to indicate line breaks. On Unix-based systems (Unix, Linux, Mac OS X), this is '\n'. However, if you want to emulate a Windows system, you can change this to '\r\n' to represent the carriage return and … Re: Ignore CRLF ("\r\n") in a csv file Programming Software Development by TrustyTony Could be that you are prefering too much to use readline. In Python it is good to prefer to use open('file.csv', 'rb') the binary mode might be necessary to turn off the Python magic processing of new lines. If you could give sample of your original input, maybe I could give simple input solution for that even without csv module. Re: Catch CrLf Characters Programming Software Development by gspeedtech After searching for possible solutions, I tried this: At the point in the code where the data is prepared before it is uploaded to SQL I added this code: Imports System.Text.RegularExpressions And replaced this: CustomerName = txtCustomerName With this: CustomerName = Regex.Replace(txtCustomerName, "[^A-Za-z0-9\-/]", &… Re: Catch CrLf Characters Programming Software Development by Unhnd_Exception [QUOTE=;][/QUOTE] I don't see anything wrong with codeorder's example. Heres his version that searches a byte array with the vbcrlf and replaces. [code] Dim sTemp As String = "some" & vbNewLine & vbNewLine & "text" Dim mStream As New System.IO.MemoryStream Dim bWriter As New System.IO.BinaryWriter(… Re: Catch CrLf Characters Programming Software Development by gspeedtech Awesome, I inserted this code: If .CompanyName.Contains(CChar(vbCrLf)) Then .CompanyName = .CompanyName.Replace(vbCrLf, " ") End If Works great! Thanks all! Re: Catch CrLF in a Transaction File Programming Software Development by codeorder Have you tried [iCODE]TransactionFile.ToString[/iCODE]? [URL="http://www.daniweb.com/software-development/vbnet/threads/356022/1516455#post1516455"]This [/URL]might also be of some help. Re: Catch CrLF in a Transaction File Programming Software Development by codeorder Have you tried a For/Next loop, to loop through all fields in the collection and replace data in each field if needed? Re: Catch CrLF in a Transaction File Programming Software Development by gspeedtech [QUOTE=codeorder;1574587]Have you tried a For/Next loop, to loop through all fields in the collection and replace data in each field if needed?[/QUOTE] Thanks for the reply, My problem is, according to my limited knowledge, "Replace" only works on String objects. How do you For/Next through a collection of Objects and target only … Re: Catch CrLF in a Transaction File Programming Software Development by codeorder Cannot state what is unknown. If possible, post your collections code and how you get a certain object/value from it. Also, if the collection loads from a file, post some of the file content as well. .Should be easy to try and provide a solution then, hopefully. Re: Catch CrLF in a Transaction File Programming Software Development by gspeedtech Pardon my failure to adequately describe my inquiry. This is an example of the code I am dealing that creates a transaction. The transaction is converted to XML and then exported. (I have changed the names in hopes of retaining confidentiality hopefully without breaking it) [CODE]Function BuildMasterTransaction(ByVal DSTransaction As … Re: Catch CrLF in a Transaction File Programming Software Development by codeorder See if this helps. [CODE] Dim dt As New DataTable With dt '// FOR TESTING. 2 Columns with 2 Rows. With .Columns : .Add("1") : .Add("2") : End With With .Rows : .Add("a" & vbCrLf & "1", "b" & vbCrLf & "1") : .Add("a2" & … Re: Catch CrLF in a Transaction File Programming Software Development by gspeedtech I can use: [CODE]Public Function ScrubData(ByRef STransaction) Dim sTable As New ProjectSchema.Transaction() Dim row1 As String sTable = STransaction row1 = sTable.LastName() If row1 <> " " Or row1 <> "" Then Regex.Replace((… Re: Catch CrLF in a Transaction File Programming Software Development by gspeedtech For some reason I can see Replies to this post on my IPhone, but they dont appear when I access from my laptop or Workstation at work. To Respond to mail.sandhya2: Question : Why we have to create the transaction file? Its complicated and not part of my resposibilities to redesign the system. A transaction file is created and converted to an…