Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我应该如何解析input.mov文件中的数据,并将解析后的数据输出到单独的.txt文件中?_Php_C++_Parsing_Text - Fatal编程技术网

Php 我应该如何解析input.mov文件中的数据,并将解析后的数据输出到单独的.txt文件中?

Php 我应该如何解析input.mov文件中的数据,并将解析后的数据输出到单独的.txt文件中?,php,c++,parsing,text,Php,C++,Parsing,Text,我有一个.mov文件,当在文本编辑器中编辑时,它会显示一组信息。我想创建一个程序来提取信息并创建一个.txt文件,这样我可以在每个月得到一个新的.mov文件时运行它 下面是.mov文件中的信息 [Categories] 1 hollywoodhd 1295 1295 Movies 1 2 mega 1095 1095 Movies 1 3 still 1095 1095 Movies 1 4 special 895 895 Mo

我有一个.mov文件,当在文本编辑器中编辑时,它会显示一组信息。我想创建一个程序来提取信息并创建一个.txt文件,这样我可以在每个月得到一个新的.mov文件时运行它

下面是.mov文件中的信息

[Categories]
1   hollywoodhd 1295    1295    Movies  1
2   mega    1095    1095    Movies  1
3   still   1095    1095    Movies  1
4   special 895 895 Movies  1
5   family  1095    1095    Movies  1

[Titles]
  hollywoodhd1 1 0 8046 0 919 PG-13 6712 1 identity_hd "(HD) Identity Thief" Disk 0 04/15/13 11/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd2 3 0 8016 0 930 PG 5347 1 escapep_hd "(HD) Escape from Planet Earth" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd3 1 0 8012 0 930 PG-13 5828 1 darkski_hd "(HD) Dark Skies" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd3 2 0 8007 0 928 PG-13 5735 1 guilttri_hd "(HD) The Guilt Trip" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd3 3 0 8013 0 928 PG-13 7813 1 jackreac_hd "(HD) Jack Reacher" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
  hollywoodhd4 1 0 7993 0 919 PG-13 9500 1 lesmiser_hd "(HD) Les Miserables" Disk 0 03/06/13 09/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
在[Titles]之后,我只需要将电影的名称和分级放在文本文件中。如果可能的话,我想提示用户选择从哪个文件读取,这样任何人都可以在其他人运行该程序时键入文件的名称或路径

我正计划使用C++。关键是让它自动化,这样我就可以每月运行该程序,只需取出电影标题和分级,而不是将其复制粘贴到word中并删除所有其他内容。

在Python中(不是“正确”的方式),但足够通用:

dict = {} # Movie titles and ratings

# open up the .mov file, check for tell-tale patterns and pair them up
with open('yourfilehere.mov', 'r') as infile:
    for line in infile.readlines():
        for word in line.split():
            if word in ['G', 'PG', 'PG-13', 'R', 'X']:
                hold = word
            elif word[0] == '"' and word[-1] == '"':
                dict[word[1:-1]] = hold

# write the pairings into a new file, separated by a tab                
with open('output.txt', 'w') as outfile:
    for key in dict.keys():
        outfile.write(key + "\t" + dict[key] + "\n")

希望这足以用自己的代码为您指明正确的方向。考虑寻找一个用于处理.MOV元数据的库,或者至少找到一个关于如何构建MOV文件的好资源。

< P>我会给你一些伪代码,关于如何解析该文件:

void Read(stringFileName)
{
     //very self explanatory
}

int FindStr(stringToFind, stringToSearchWith, charDelimeter)
{

    //process
    return indexOfDelimeter;
}

    //stringToFind          - what data in the text are you looking for
    //stringToSearchWith    - in what text should I look for this(assuming you stored the .txt file into a string
    //charDelimeter         - whats the next character after finding the stringToFind.
    //                      - this is important so that you can know whats the corresponding data in that string e.g myFavNum 10000000e-210
    //the delimeter is a `space`

int ConvertToInt(stringToSearchWith, index)
{
    //process
    return toInt;
}

    //stringToSearchWith - assuming that this is only a line in your .txt file,
    //                   - this is where you want to convert string into int
    //index              - where is the data in the string?
总结:

  • 读取

  • 查找

  • 转换


  • 如果不限制问题的范围,就不太可能得到答案。www.sscce.org如果还有视频信息,请使用现有媒体解码器获取文件头。由于您的请求非常具体,您可能希望避免编写编译程序。脚本编写是解决此类问题的常见做法。Python、PHP、Lua等是您的一些选项。您应该自己做解析器。了解如何操作文本文件中的字符串以及这些文本是如何排列的是你的目标。嘿,很抱歉这个令人困惑的问题。这是我的第一个问题。对于所有阅读这个例子并感到恶心的人,我感到很抱歉。看起来这个人只是想乱搞一些代码,需要朝着正确的方向努力。