将* .rsc文本文件转换为表格数据 [英] Covert *.rsc text file to tabluar data

查看:64
本文介绍了将* .rsc文本文件转换为表格数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我没有转换非csv或其他表格结构的文本的经验.
我获取数据的唯一方法是在如下所示的文本文件中.
我已经尝试了很多方法:

Hello all,

I have no experience converting text not in csv or other tabluar structure.
The only way I get data is in a text file like below.
I have tried many ways with this:

    <script language="c#" runat="server">
  public void Page_Load(object sender, EventArgs e)
{
    string FILENAME = Server.MapPath("users_db_match.txt");
    StreamReader objStreamReader = default(StreamReader);
	objStrea<code><code><code></code></code></code>mReader = File.OpenText(FILENAME);
    string contents = objStreamReader.ReadToEnd();
    string strData = contents ;
    char[] separator = new char[] { '\\' };
    string[] strSplitArr = strData.Split(separator);
    foreach (string arrStr in strSplitArr)
    {
     Response.Write(arrStr + " ");
    }



但是我没有运气.这是文本结构的示例:



But I am having no luck. Here is an example of the text structure:

 # Senseless text
    # 
    #
    /from what folder
    add comment="" customer=Multi disabled=no first-name=Joseph last-           name=Won \
    location="6333 Co. Rd 53 Where, AL 35045" name=joeandstacy password=\
    took1 shared-users=3
add comment="" customer=Multi disabled=no email=carl_l@yahoo.com \
    first-name=Carl last-name=Pop location=\
    "6359 Co. Rd 53 Townin, AL 35045" name=carl_l password=\
    20579 phone=205-755-5555 shared-users=3




列紧接在=之前,数据紧接在之后. \在记录中间将文本分成新行.
客户禁用的电子邮件名字
多无卡尔
多无carl_l@yahoo.com约瑟夫


我什至在使用字符串函数的写入轨道上吗?一旦将其转换为excel可以读取的csv或其他格式,我将再次将新结构另存为文件.我知道这很复杂,但希望能有所帮助.谢谢.




The columns are immediately before the = and the data is immediately after. It also has \ breaking the text into new lines in the middle of a record.
Customer disabled email first-name
Multi no Carl
Multi no carl_l@yahoo.com Joseph


Am I even on the write track with the string functions? Once I get it converted to a csv or other format that excel can read I''ll save the new structure as a file again. I know this is very complicated but would appreciate any help. Thanks.

推荐答案

我建​​议为此编写自己的简单扫描器.现在不会像现在那样使用字符串函数,因为它们是通用的.您可以按照以下步骤逐个字符地对其进行处理:

您首先跳过空格:space, cr, lf, \, eof

您开始阅读列名(直到遇到"="号为止):a-z,-

您读取的值可以是:
1.在第一个和第二个引号之间:"... ..."
2.直到遇到空白:...

重复这些步骤,直到完成.编写简单的方法来处理每个步骤,您将很快完成.

祝您好运!
I would recommend writing your own simple scanner for this. Using the string functions like you are doing now won''t do because they are to generic for this. You process it character by character following these steps:

You first skip whitespace: space, cr, lf, \, eof

You start reading the column name (until you encounter the "=" sign): a-z,-

You read the value, this can be:
1. between first en second quote: "... ..."
2. Until you encounter a white space: ...

Repeat those steps until you are done. Write simple methods for dealing with each single step and you''ll be done in no-time.

Good luck!


不是要完全在黑暗中发声,但是您会建议使用哪种类型的简单扫描仪"设置?我通过google进行了字面上的asp.net C#代码扫描程序搜索,但没有任何内容引起我的注意.至少现在我知道字符串函数在错误的盟友中失败了.感谢您的帮助.
Don''t mean to sound totally in the dark but what type of "simple scanner" setup would you suggest? I did a literal search through google for asp.net C# code scanner and nothing caught my attention. At least now I know the string function was going down the wrong ally. I appreciate all the help.


这篇关于将* .rsc文本文件转换为表格数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆