红尘中的碧玉石竹花的缤纷舞步

一、红尘中的碧玉:石竹花的缤纷舞步

二、碧玉之姿,石竹花的独特美学

三、滋养生长:石竹花与土壤环境的关系

四、风中轻摇,石竹花在传统文化中的地位

五、生态保护者:石竹花如何维护自然平衡

六、医药宝库:古人对石竹花提取物的应用探究

七、色彩繁多,植物分类学中的stonecrop科探索

八、二千年来,中国园林艺术中的栽培技巧演变史迹考察

import os

import re

from typing import List, Tuple, Dict, Set # noqa: F401

def find_files(path: str) -> List[str]:

"""Find all files in a directory"""

return [os.path.join(path, f) for f in os.listdir(path)]

def parse_file(file_path: str) -> Tuple[Dict[str, Any], List[Any]]:

"""Parse a file and extract relevant information"""

with open(file_path, 'r') as file:

content = file.read()

lines = content.splitlines()

data = {}

metadata = []

for line in lines:

match = re.match(r'^(\w+): (.*)', line)

if match:

key, value = match.groups()

data[key] = value

else:

metadata.append(line)

return data, metadata

if __name__ == '__main__':

path_to_data_folder = 'path/to/data/folder'

files_in_data_folder = find_files(path_to_data_folder)

for file_path in files_in_data_folder:

_, metadata_lines_list_of_strings_tupled_with_line_number_and_line_content \

= parse_file(file_path)

# print(metadata_lines_list_of_strings_tupled_with_line_number_and_line_content)

# print(data_dict_from_json_string(str(json.loads(metadata_lines_list_of_strings_tupled_with_line_number_and_line_content[0][1]))))

package main

import (

"fmt"

"io/ioutil"

"os"

"path/filepath"

"regexp"

)

func findFilesInDirectory(dir string) ([]string, error){

files := []string{}

err := filepath.Walk(dir,

func(filePath string,

info os.FileInfo,

err error) {

if err != nil {

return

}

files= append(files , filePath )

})

return files,err

}

func parseFile(filePath string)(map[string]string,map[string]string,error){

dataMap:= map[string]string{}

metadataMap:= map[string]string{}

fileContent,err := ioutil.ReadFile(filePath)

if err!=nil{

return nil,nil,err

}

contentStr := string(fileContent)

linesArr:= strings.Split(contentStr,"\n")

for i,lineStr,_:=range linesArr{

match,_= regexp.Compile("^(\w+): (.*)")

matchResult:=match.FindStringSubmatch(lineStr)

if len(matchResult)>0 {

key,value:=matchResult[1],matchResult[2]

dataMap[key]=value

} else {

metadataMap["line_"+strconv.Itoa(i)+"_content"]=lineStr

}

return dataMap,metadataMap,nil

}

func main(){

pathToDataFolder := "path/to/data/folder"

filesInDataFolder,err := findFilesInDirectory(pathToDataFolder)

if err!=nil{

panic(err

}

for _,filePathString := range filesInDataFolder {

dataMap,madataMetadata,err2:=parseFile(filePathString)

// print(dataMap);

// println(madataMetadata);

猜你喜欢