Home > Software engineering > Vb, how to read the irregular text files, to the XLS spreadsheet. Such as TXT file is as follows:
Vb, how to read the irregular text files, to the XLS spreadsheet. Such as TXT file is as follows:
Time:03-03
Vb, how to read the irregular text files, to the XLS spreadsheet. Such as TXT file is as follows: 50122219800198 guizhou transaction type: 2 price yellow male address: 139081352555 Beijing road downtown 3 50122219800185 henan transaction type: 2 price Li Wu female 139081352555 address: Shanghai downtown road ziyun street 13 Transaction type: 50122219800152 Beijing 2 price LuHong male address: 139081352555 nanjing road downtown houjie 26 5012221980016522 sichuan transaction type: 1 price Li Siwa male address: 139081352555 sichuan road sika deer street downtown 19 This text file space is likely to be among the blank space key, the TAB key or other keys, the TXT file is very big, there are 20 m or so, as far as possible some more details, thanks!
CodePudding user response:
Don't be afraid of the file is big, 20 m small files, For what do you think of the file, do first filing Consider you deal with the frequency of this file, if is a one-time processing, so using readily available tools for formatting work to go, if it is to consider the need to handle such frequent files use script processing, No matter use a program or a tool, the first step, first make clear the rules of the file, such as data lines of the separator is what, field use delimiters or treated with fixed length, there are always rules, in accordance with the rules, for some uncertain long useless data such as Spaces, if you can differentiate into a field that is assigned to the fields to trim, If really don't know the rules, but just want to meet the continuous space when the separator, so I like to use UE text editing tools, such as search two Spaces, and replaced with a space, repeated several times, when he said can't find a continuous two Spaces, and all documents of continuous Spaces have been replaced with a space,
So processed again data rows and fields, such as separation of simple,
CodePudding user response:
Regular expressions can understand it.
CodePudding user response:
Read one line, each row "pretreatment" (replace operation), and then to "field separation," The separation results into Excel each line...