简体   繁体   English

如何在 csv 文件中表示嵌套值? 我想将文件无缝加载到(嵌套的)python 字典中

[英]How to represent nested values in a csv file? I want to seamlessly load the file into a (nested) python dictionary

My first thought is to chain csv files together through references.我的第一个想法是通过引用将 csv 文件链接在一起。 This will keep the information of each cell simple.这将使每个单元格的信息保持简单。 A potential problem may arise if the chains become long and finding the correct csv file to edit becomes too complicated.如果链变长并且找到要编辑的正确 csv 文件变得过于复杂,则可能会出现潜在问题。

demographics:
    description: This is a description of demographics
        type: string
            value:
                ethnicity:
                        -a
                        -b
                        -c
    node: node801832
    somerandom:
        random1: 201901
        random2: lkk133

A column in popdemographics.csv
demographics        
description.csv     
node.csv        
somerandom.csv      


The csv file referenced by description.csv
description     
This is a description of demographics       
type.csv

This is not possible in csv.这在 csv 中是不可能的。 You might consider using YAML if you want readability for 'non-techies'如果您希望“非技术人员”的可读性,您可以考虑使用 YAML

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM