Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.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
Python 处理输入Excel文件并序列化其行_Python_Excel_Class_Serialization_Boo - Fatal编程技术网

Python 处理输入Excel文件并序列化其行

Python 处理输入Excel文件并序列化其行,python,excel,class,serialization,boo,Python,Excel,Class,Serialization,Boo,我必须解决一个练习,但我不能解决一个错误。 对不起,我不太懂Boo语言。 我的代码是: public class Item (IIDataReaderLoadable): Sequence as long Code as string Description as string Weight as decimal Id as Guid def LoadFromReader(reader as IDataReader): Sequence = long.Pars

我必须解决一个练习,但我不能解决一个错误。 对不起,我不太懂Boo语言。 我的代码是:

public class Item (IIDataReaderLoadable):
  Sequence as long
  Code as string
  Description as string
  Weight as decimal
  Id as Guid


  def LoadFromReader(reader as IDataReader):
    Sequence = long.Parse(reader[0].ToString());
    Code = reader[1].ToString();
    Weight = decimal.Parse(reader[2].ToString());
    Description = reader[3].ToString();
    Id = Guid.Parse(reader[4].ToString());
  TableName as string:  
    get:
        return "Hoja1$"


 operation read_MasterData_etlexcel:
   log = ProcessContext.GetLogger()
   file = ProcessContext.InputFile
   log.Info("Reading $file")
   for Data in EntityReader[of Item].Read(file):
       yield Row.FromObject(Data)

 operation print_etlexcel:
   log = ProcessContext.GetLogger()
   for row in rows:
      log.Info(row.ToString())
      yield row

def serialize_row(it as Object, id as Guid):
   serializer = XmlSerializer(typeof(Item))
   writer = FileStream("output" + id.ToString() +".xml", FileMode.Create);
   serializer.Serialize(writer, it);
   writer.Close();

serialize_row(Item, Item.Id)

process process_owners_etlexcel:
   read_MasterData_etlexcel()
   print_etlexcel()
当我在命令窗口中执行它时,会出现下一个错误:

2018-05-14 14:18:44.0479 [Error] [Mss.Etl.DSLLoader.EtlSetup] Cannot execute ./e
xcelfile/import.boo BCE0000: C:\Program Files\Mecalux\GnaService2015\excelfile\i
mport.boo(57,30): BCE0020: Boo.Lang.Compiler.CompilerError: An instance of type
'Mss.Item' is required to access non static member 'Id'.
我想读取一个包含一些列的Excel文件,我必须创建一个恢复Excel文件内容的boo脚本,然后我必须将Excel文件中的每一行映射到我的类Ítem的对象中,并将该对象序列化为XML文件


谢谢

错误在这行:

serialize_row(Item, Item.Id)
Id字段是成员字段而不是静态字段,这意味着您需要一个实例。看起来你把它叫做静电,所以它爆炸了。我不确定解决方案是什么,因为有两个宏没有在代码示例中定义,所以我不确定它们在做什么,但我认为您需要删除该行或传入成员id或随机id

我猜这就是解决方案:

item = Item()
serialize_row(item, item.Id)

什么语言<代码>phynton?那是python吗?是的,它使用phynton语言好的,谢谢。您好,玛丽亚,据我所知,您在理解
python
时遇到了一些主要问题。这看起来不像python。也许做一些教程会帮助你解决问题(尤其是:许多其他即将出现的问题),比询问答案快得多。您好,这真的是boo语言,它基于Python语言,