我是初学者,所以请不要发誓。 我使用Postgresql,但没有成功。出错了。 我需要将Excel文件导入到现成的表中。 电子表格excel组成
Ruby代码:
def self.import_csv
text = File.read("/home/dayanov-sa/Рабочий стол/копия инвест карты/ExportInventoryData.xlsx")
csv = CSV.parse(text, :headers => true)
csv.each do |row|
row = row.to_hash.with_indifferent_access
candidate = ImportPropertyObject.new(row)
candidate.save
end
我需要将所有列加载到数据库中
id serial NOT NULL,
ao_1_aoid character varying,
ao_1_shortname character varying,
ao_1_formalname character varying,
ao_1_node_id integer,
ao_2_aoid character varying,
ao_2_shortname character varying,
ao_2_formalname character varying,
ao_2_node_id integer,
ao_3_aoid character varying,
ao_3_shortname character varying,
ao_3_formalname character varying,
ao_3_node_id integer,
ao_4_aoid character varying,
ao_4_shortname character varying,
ao_4_formalname character varying,
ao_4_node_id integer,
ao_5_aoid character varying,
ao_5_shortname character varying,
ao_5_formalname character varying,
ao_5_node_id integer,
ao_village_council_aoid character varying,
ao_village_council_shortname character varying,
ao_village_council_formalname character varying,
ao_village_council_node_id integer,
village_council_guid character varying,
locality_guid character varying,
exam_card character varying,
all_correct character varying,
cadastre_number character varying,
condition_number character varying,
oks_kind character varying,
endpoint_guid character varying,
stead_number character varying,
house_number character varying,
build_number character varying,
struc_number character varying,
room_number character varying,
level_number character varying,
linked_exam_card_numbers character varying,
permitted_usage character varying,
purpose_use character varying,
actual_use character varying,
footage character varying,
wall_material character varying,
levels_count character varying,
underground_levels character varying,
manufactured_year character varying,
overhaul_year character varying,
infra_electricity character varying,
infra_gas character varying,
infra_water character varying,
infra_heat character varying,
infra_sewer character varying,
land_type character varying,
subject_of_law_type character varying,
discrepancy_footage character varying,
discrepancy_boundary character varying,
discrepancy_use character varying,
discrepancy_unautorized_actions character varying,
discrepancy_wall_material character varying,
discrepancy_levels_count character varying,
discrepancy_level_mismatch character varying,
discrepancy_living_type character varying,
discrepancy_factal_cadastre_quartal character varying,
duplicate_exam_card_number character varying,
type_of_law character varying,
subject_of_law character varying,
basis_document character varying,
basis_document_number character varying,
basis_document_date character varying,
foto_1_name character varying,
foto_2_name character varying,
cause_of_change character varying,
spec_note_owner_resistance character varying,
spec_note_invalid_exam_card character varying,
spec_note_factal_absent character varying,
spec_note_additional_notes character varying,
correct_landmark_information_presence character varying,
general_data_hash character varying,
service_content json,
update_date timestamp without time zone,
actual_status integer,
status_date timestamp without time zone,
counted integer,
type_property integer,
founded_in_fias boolean DEFAULT false,
founded_in_rosreestr boolean DEFAULT false,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
fias_ao_guid character varying,
file_path character varying,
CONSTRAINT import_property_objects_pkey PRIMARY KEY (id)
错误之一: 2.4.4:015> StatisticReportsGroup.import_csv
ArgumentError:UTF-8中的无效字节序列