<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://www.wiki.prgarnett.net/index.php?action=history&amp;feed=atom&amp;title=CypherCode%3ALineReader</id>
	<title>CypherCode:LineReader - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.wiki.prgarnett.net/index.php?action=history&amp;feed=atom&amp;title=CypherCode%3ALineReader"/>
	<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;action=history"/>
	<updated>2026-04-21T18:39:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=17&amp;oldid=prev</id>
		<title>Phil at 11:49, 23 December 2019</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=17&amp;oldid=prev"/>
		<updated>2019-12-23T11:49:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:49, 23 December 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Its &lt;/del&gt;great for building a network offline in a text file, and then you can simply run the program and it will put the data in neo4j.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;It&#039;s &lt;/ins&gt;great for building a network offline in a text file, and then you can simply run the program and it will put the data in neo4j.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Obviously you need to provide it with the server address, and a username/password if needed. It just runs so make sure you don&amp;#039;t send all the data to the wrong place!&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Obviously you need to provide it with the server address, and a username/password if needed. It just runs so make sure you don&amp;#039;t send all the data to the wrong place!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=9&amp;oldid=prev</id>
		<title>Phil at 21:06, 7 December 2017</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=9&amp;oldid=prev"/>
		<updated>2017-12-07T21:06:17Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:06, 7 December 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l76&quot;&gt;Line 76:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 76:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         try (Transaction tx = session.beginTransaction())&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         try (Transaction tx = session.beginTransaction())&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;            &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;            System.out.println(line);&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             tx.run(line);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             tx.run(line);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             tx.success();&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;             tx.success();&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
	<entry>
		<id>http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=8&amp;oldid=prev</id>
		<title>Phil: Created page with &quot;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. Its great for...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.wiki.prgarnett.net/index.php?title=CypherCode:LineReader&amp;diff=8&amp;oldid=prev"/>
		<updated>2017-12-07T14:03:51Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. Its great for...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a really simple project that loads data from a file and put it into a Neo4J data. It assumes that each line of the file is an individual cypher command. Its great for building a network offline in a text file, and then you can simply run the program and it will put the data in neo4j.&lt;br /&gt;
&lt;br /&gt;
Obviously you need to provide it with the server address, and a username/password if needed. It just runs so make sure you don&amp;#039;t send all the data to the wrong place!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=java style=&amp;quot;border:3px dashed blue&amp;quot;&amp;gt;&lt;br /&gt;
package net.prgarnett.cypherlinereader;&lt;br /&gt;
&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileNotFoundException;&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
import org.neo4j.driver.v1.AuthTokens;&lt;br /&gt;
import org.neo4j.driver.v1.Driver;&lt;br /&gt;
import org.neo4j.driver.v1.GraphDatabase;&lt;br /&gt;
import org.neo4j.driver.v1.Session;&lt;br /&gt;
import org.neo4j.driver.v1.Transaction;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author philip&lt;br /&gt;
 */&lt;br /&gt;
public class LineReader {&lt;br /&gt;
    &lt;br /&gt;
    private final Driver driver;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Load up the driver, using the address, pword, and username.&lt;br /&gt;
     * &lt;br /&gt;
     * @param serveradd&lt;br /&gt;
     * @param password&lt;br /&gt;
     * @param username &lt;br /&gt;
     */&lt;br /&gt;
    public LineReader(String serveradd, String password, String username)&lt;br /&gt;
    {&lt;br /&gt;
        this.driver = GraphDatabase.driver(serveradd, AuthTokens.basic(username, password));&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Give the method the path to the file, it will read any line that does not&lt;br /&gt;
     * start with a &amp;#039;#&amp;#039;.&lt;br /&gt;
     * &lt;br /&gt;
     * @param path &lt;br /&gt;
     */&lt;br /&gt;
    public void ExecuteLines(String path)&lt;br /&gt;
    {&lt;br /&gt;
        try{&lt;br /&gt;
            File targetFile = new File(path);&lt;br /&gt;
        &lt;br /&gt;
            try(Session session = driver.session())&lt;br /&gt;
            {&lt;br /&gt;
                Scanner lineScanner = new Scanner(targetFile);&lt;br /&gt;
                while(lineScanner.hasNext())&lt;br /&gt;
                {&lt;br /&gt;
                    String line = lineScanner.nextLine();&lt;br /&gt;
                    if(!line.startsWith(&amp;quot;#&amp;quot;))&lt;br /&gt;
                    {&lt;br /&gt;
                        this.processLine(line, session);&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        catch (FileNotFoundException e)&lt;br /&gt;
        {&lt;br /&gt;
            System.err.println(e.getMessage());&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     * Private method that processes the line in a transaction, requires the&lt;br /&gt;
     * session to be past.&lt;br /&gt;
     * &lt;br /&gt;
     * @param line&lt;br /&gt;
     * @param session &lt;br /&gt;
     */&lt;br /&gt;
    private void processLine(String line, Session session)&lt;br /&gt;
    {&lt;br /&gt;
        try (Transaction tx = session.beginTransaction())&lt;br /&gt;
        {&lt;br /&gt;
            tx.run(line);&lt;br /&gt;
            tx.success();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Phil</name></author>
	</entry>
</feed>