示例#1
0
文件: Parser.cs 项目: nvelaborja/451
        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");
        }
示例#2
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");
        }