Comcast’s Monetary Influence Over Illinois Political Candidates

I found an interesting dataset on political contributions in the state of Illinois.. The downloadable .zip contains multiple tab delimited database files which contain the relationships between Donations, Committees, and Candidates.

Out of curiosity in seeing Comcast’s political influence in Illinois over time, I parsed the 650,775mb file called Receipts.txt. Below is a bar chart of yearly recorded donation totals from 2000 through 2015-08.

Comcast_DPolitical_Donations_2000-2015-6_2

Not being very politically oriented, I wanted to somehow relate the donations to candidates. But in the form of the available data, it appears Donors make contributions to Committees, and Committees support a Candidate. But I do not know if Candidates and Committees are a One to One relationship at the time of typing this.

Parsing the text file called CmteCandidateLinks.txt, I related the Committee Id with the candidate Id. Parsing the text file called Candidates.txt I relate the Candidate Id to the Candidate name.

Lots of candidate duplicates per donation entry. Majority of Committees represent the same candidate under different ids, while some committees represent multiple candidates. Example here:

donations-2-commit-2-candids

So I decided to distribute each donation amount between a potential multitude of candidates. I did this by dividing each donation by the number of candidates which belong to the committee recipient. From that, I got this list of Comcast’s Top Illinois Candidates.

top_20_illinois_Candidates_Recieve_Donation_from_Comcast

C# Console Application used to create Top 20 Comcast Candidate chart.

Console.BufferHeight = 4000;
Dictionary<string, float> candid_donation = new Dictionary<string, float>();
Dictionary<string, string> dictCandId2Name = new Dictionary<string, string>();
Dictionary<string, List<string>> dictComm_CandList = new Dictionary<string, List<string>>();
 
string line_candid;
System.IO.StreamReader fileCandid =
    new System.IO.StreamReader(@"C:\IL_Campaign_Disclosure\data\Candidates.txt");
 
while ((line_candid = fileCandid.ReadLine()) != null)
{
    string[] parts = line_candid.Split('\t');
    string name = parts[1] + "   " + parts[2];
    string id = parts[0];
    dictCandId2Name.Add(id, name);
}
string line_relation;
System.IO.StreamReader fileRelay =
    new System.IO.StreamReader(@"C:\IL_Campaign_Disclosure\data\CmteCandidateLinks.txt");
 
while ((line_relation = fileRelay.ReadLine()) != null)
{
    string[] parts = line_relation.Split('\t');
    string Comm_id = parts[1];
    string Candid_id  = parts[2];
    Console.WriteLine( Comm_id + "   " +Candid_id);
    if ( dictComm_CandList.ContainsKey(Comm_id))
    {
        List<string> existing = dictComm_CandList[Comm_id];
        existing.Add(Candid_id);
        dictComm_CandList[Comm_id] = existing;
    }
    else
    {
        List<string> temp = new List<string>();
        temp.Add(Candid_id);
        dictComm_CandList.Add(Comm_id, temp);
    }
}
Dictionary<string, float> dict_YearTot = new Dictionary<string, float>();
float total = 0;
string line;
System.IO.StreamReader file =
    new System.IO.StreamReader(@"C:\IL_Campaign_Disclosure\data\Receipts.txt");
while ((line = file.ReadLine()) != null)
{
    try
    {
        string[] parts = line.Split('\t');
        string fn = parts[4];
        string ln = parts[5];
        string amount = parts[7];
        string date = parts[6];
        string comm_id = parts[1];
        if (fn.ToLower().Contains("comcast") || ln.ToLower().Contains("comcast"))
        {
            float money = float.Parse(amount);
            Console.WriteLine(fn + "  " + ln + "   " + money + "   " + date);
            if ( dictComm_CandList.ContainsKey(comm_id))
            {
                List<string> candlist = dictComm_CandList[comm_id];
                float eachRecipientShare = money / float.Parse(candlist.Distinct().Count().ToString());
                foreach (string cand in candlist)
                {
                    Console.WriteLine(candlist.Count);
                    Console.WriteLine(cand + "    " + dictCandId2Name[cand] + "   " + eachRecipientShare);
                    string cand_name = dictCandId2Name[cand];
                    if ( candid_donation.ContainsKey(cand_name) )
                    {
                        float existing = candid_donation[cand_name];
                        existing += eachRecipientShare;
                        candid_donation[cand_name] = existing;
                    }
                    else
                    {
                        candid_donation.Add(cand_name, eachRecipientShare);
                    }
                }
            }
        }
    }
    catch (Exception x)
    {
        Console.WriteLine("\r\n\r\nWhat?" + x.ToString());
    }
}
file.Close();
Console.WriteLine(string.Format("{0:C}", total));
foreach (string cand in candid_donation.Keys)
{
    Console.WriteLine(cand + "         " + candid_donation[cand]);
}
Console.WriteLine();
string output = "";
foreach (KeyValuePair<string, float> item in candid_donation.OrderByDescending(key => key.Value))
{
    Console.WriteLine("['"+item.Key + "', " +Math.Round(item.Value,0)+"],\r\n");
    string json_line = "['" + item.Key + "', " + Math.Round(item.Value, 0) + "],\r\n";
    output += json_line;
}
StreamWriter streamWrite;
streamWrite = File.AppendText("C:\\Airplanes\\TopCandids.txt");
streamWrite.WriteLine(output);
streamWrite.Close();

Leave a Reply

Your email address will not be published. Required fields are marked *