Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            JSONParser my_parser = new JSONParser();

            //Parse yelp_business.json
            my_parser.parseJSONFile(dataDir + "yelp_business.json", dataDir + "business.sql");

            //Parse yelp_review.json
            my_parser.parseJSONFile(dataDir + "yelp_review.json", dataDir + "review.sql");

            //Parse yelp_user.json
            my_parser.parseJSONFile(dataDir + "yelp_user.json", dataDir + "user.sql");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            JSONParser my_parser =  new JSONParser();

            //Parse yelp_business.json
            my_parser.parseJSONFile(dataDir + "yelp_business.json", dataDir + "business.sql");

            //Parse yelp_review.json
            my_parser.parseJSONFile(dataDir+"yelp_review.json",dataDir+"review.sql");

            //Parse yelp_user.json
            my_parser.parseJSONFile(dataDir + "yelp_user.json", dataDir + "user.sql");
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            JSONParser my_parser = new JSONParser();

            //Parse yelp_business.json
            my_parser.parseJSONFile(dataDir + "yelp_business.json", dataDir + "business.txt");

            //Parse yelp_user.json
            my_parser.parseJSONFile(dataDir + "yelp_user.json", dataDir + "user.txt");

            //Parse yelp_tip.json
            my_parser.parseJSONFile(dataDir + "yelp_tip.json", dataDir + "tip.txt");

            //Parse yelp_checkin.json
            my_parser.parseJSONFile(dataDir + "yelp_checkin.json", dataDir + "checkin.txt");
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            JSONParser my_parser = new JSONParser();

            try
            {
                File.Delete(dataDir + "sub/insertIntoTables.sql");
            }
            catch (Exception)
            {
            }

            //Parse yelp_business.json
            my_parser.parseJSONFile(dataDir + "yelp_business.json", dataDir + "business.sql");

            using (StreamWriter w = File.AppendText(Parser.dataDir + "sub/insertIntoTables.sql"))
            {
                foreach (string k in ParseJSONObjects.value.Keys)// k = business_id
                {
                    KeyValuePair <Hashtable, List <string> > tmp = (KeyValuePair <Hashtable, List <string> >)ParseJSONObjects.value[k];

                    foreach (string s in tmp.Value)// s = category
                    {
                        if (ParseJSONObjects.atb.ContainsKey(s))
                        {
                            //string com = "update " + s + " set ";
                            foreach (string z in (ParseJSONObjects.atb[s] as List <string>))// z = attributes
                            {
                                if (tmp.Key.ContainsKey(z))
                                {
                                    //com += z + "='" + tmp.Key[z] + "', ";
                                    w.WriteLine("insert into attributes values ('" + k + "', '" + z + "', " + "'" + tmp.Key[z] + "'" + ");");
                                    w.WriteLine("insert into Categories values ('" + k + "', '" + s + "', " + "'" + z + "'" + ");");
                                }
                            }
                            //w.WriteLine(com.Substring(0, com.Length - 2) + " where business_id='" + k + "';");
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            JSONParser my_parser = new JSONParser();

            //try
            //{
            //    File.Delete(dataDir + "/business.sql");
            //}
            //catch (Exception)
            //{

            //}

            //try
            //{
            //    File.Delete(dataDir + "/review.sql");
            //}
            //catch (Exception)
            //{

            //}

            try
            {
                File.Delete(Parser.dataDir + "/sub/req/zip.sql");
            }
            catch (Exception)
            {
            }


            try
            {
                File.Delete(dataDir + "/sub/Category.sql");
            }
            catch (Exception)
            {
            }

            try
            {
                File.Delete(dataDir + "/sub/insertIntoCatTables.sql");
            }
            catch (Exception)
            {
            }

            try
            {
                File.Delete(dataDir + "/sub/req/Create_Cats.sql");
            }
            catch (Exception)
            {
            }

            try
            {
                File.Delete(dataDir + "/sub/Cats.sql");
            }
            catch (Exception)
            {
            }



            //Parse yelp_business.json
            my_parser.parseJSONFile(dataDir + "yelp_business.json", dataDir + "business.sql");

            //save all vars, values, those things into different local files

            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/Ages_Allowed.txt"))
            {
                foreach (string k in Ages_Allowed)
                {
                    w.WriteLine(k);
                }
            }

            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/allCat.txt"))
            {
                string s = "";
                foreach (string k in Parser.allCat)
                {
                    s += k + ",";
                }
                w.WriteLine(s);
            }

            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/parameters.txt"))
            {
                foreach (string k in ParseJSONObjects.parameters)
                {
                    w.WriteLine(k);
                }
            }

            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/vars.txt"))
            {
                foreach (string k in var)
                {
                    w.WriteLine(k);
                }
            }


            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/Noise_Level.txt"))
            {
                foreach (string k in Noise_Level)
                {
                    w.WriteLine(k);
                }
            }

            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/Attire.txt"))
            {
                foreach (string k in Attire)
                {
                    w.WriteLine(k);
                }
            }

            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/Alcohol.txt"))
            {
                foreach (string k in Alcohol)
                {
                    w.WriteLine(k);
                }
            }

            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/type.txt"))
            {
                foreach (string k in type)
                {
                    w.WriteLine(k);
                }
            }
            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/BYOBCorkage.txt"))
            {
                foreach (string k in BYOB_Corkage)
                {
                    w.WriteLine(k);
                }
            }
            using (StreamWriter w = new StreamWriter(dataDir + "/sub/vars/Wi_Fi.txt"))
            {
                foreach (string k in Wi_Fi)
                {
                    w.WriteLine(k);
                }
            }


            Cates.Pop();

            string drop = "";

            using (StreamWriter w = File.AppendText(dataDir + "/sub/req/Create_Cats.sql"))
            {
                foreach (KeyValuePair <string, List <string> > k in SortToHas.cates)
                {
                    string s = "create table " + k.Key + " (";
                    drop += "drop table " + k.Key + ";";
                    foreach (string a in (k.Value as List <string>))
                    {
                        s += Cates.CTR(a);
                    }
                    s += "business_id char(22), foreign key (business_id) references business(business_id), primary key (business_id));";
                    //s = s.Substring(0, s.Length - 1) + ");";
                    w.Write(s);
                    w.WriteLine();
                }
            }

            using (StreamWriter w = new StreamWriter(dataDir + "/sub/req/drop.sql"))
            {
                w.WriteLine(drop);
                w.WriteLine("drop table cats;");
            }

            //Parse yelp_review.json
            my_parser.parseJSONFile(dataDir + "yelp_review.json", dataDir + "review.sql");

            //Parse yelp_user.json
            my_parser.parseJSONFile(dataDir + "yelp_user.json", dataDir + "User.sql");
        }