Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fX8L4-0004fe-4u for pgsql-general@arkaria.postgresql.org; Sun, 24 Jun 2018 16:58:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fX8L2-0004ww-2Y for pgsql-general@arkaria.postgresql.org; Sun, 24 Jun 2018 16:58:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fX8Kz-0004wo-Vk for pgsql-general@lists.postgresql.org; Sun, 24 Jun 2018 16:58:07 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fX8Kv-00067f-A2 for pgsql-general@lists.postgresql.org; Sun, 24 Jun 2018 16:58:04 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2D710215F2; Sun, 24 Jun 2018 12:58:00 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 24 Jun 2018 12:58:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=gQKIpvUCqK9mKn2uTn2pqMrRfhQ2z LDyks2/nx7jqY8=; b=KxHTzTioX5I+yvKiPKTDM8rL/dryeQ8tDvnW2qgK36q+7 cazOf9Dc1aRvJizn9uIrkRLXRRVlup9pvUdgJ5MyHULbvgvJb4fkNst7/Bz1hT73 c0v2A8lYMwfN875rX7dkDVqicF0vCYgHlfc4PR4J//8e6VP2PM9G+/wMHrZhv8vc G5tjiT4fffUeo1SI3hKHQ31F5KxIbdn7FfRbQcHdQJKYmp4FBSW6F/rJXIJlkXX9 YX/QzAYk7bIbtMRflAMQxPb2CCknODSAOMRL2As0lqyJK2STIGekhJLyKiJRApZ9 BA0UbwULMKZXuXaU+HSwE0Wsit7DH4mr284Q9TMXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=gQKIpv UCqK9mKn2uTn2pqMrRfhQ2zLDyks2/nx7jqY8=; b=dapzdvFo5fDQpdv6qOpfX1 569SxhcwaYgGbzWgnqA/SvgKii3Ks/fKsALTBdIG7YKhbE+waIQv3KQJ+Y12LL8g kkNLwQTfbiozzJTaXFAgwfohJJv76BNlm7fq65FYRoYLiEasSFFEDJNUWTWDt0T6 o3DNqC/M2no9erzzEc6JedUJuS9bnn0GMHU2TDyqaFoiNE0sinGQzsiNZrB7wMqQ 0KB4AQK+DCC9a3nx3EwlXuDlHyjN53+nMx6WLT4r7kBl5uquIEWAFdURDOfkeBS1 jpWQkXjEbnUFhRP7x14eM4dCaF34F7kEwgu27r8quIg2sFz6wVh0JLXVLV/U+bdg == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.159.209]) by mail.messagingengine.com (Postfix) with ESMTPA id 6AAE110252; Sun, 24 Jun 2018 12:57:59 -0400 (EDT) Subject: Re: Using COPY to import large xml file To: Anto Aravinth , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <3b83c126-c9f6-0d1e-fecc-13fc0c8e59ec@aklaver.com> Date: Sun, 24 Jun 2018 09:57:58 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 06/24/2018 08:25 AM, Anto Aravinth wrote: > Hello Everyone, > > I have downloaded the Stackoverflow posts xml (contains all SO questions > till date).. the file is around 70GB.. I wanna import the data in those > xml to my table.. is there a way to do so in postgres? It is going to require some work. You will need to deal with: 1) The row schema inside the XML is here: https://ia800107.us.archive.org/27/items/stackexchange/readme.txt - **posts**.xml 2) The rows are inside a tag. Seems to me you have two options: 1) Drop each row into a single XML field and deal with extracting the row components in the database. 2) Break down the row into column components before entering them into the database. Adrien has pointed you at a Python program that covers the above: https://github.com/Networks-Learning/stackexchange-dump-to-postgres If you are comfortable in Python you can take a look at: https://github.com/Networks-Learning/stackexchange-dump-to-postgres/blob/master/row_processor.py to see how the rows are broken down into elements. I would try this out first on one of the smaller datasets found here: https://archive.org/details/stackexchange I personally took a look at: https://archive.org/download/stackexchange/beer.stackexchange.com.7z because why not? > > > Thanks, > Anto. -- Adrian Klaver adrian.klaver@aklaver.com