├── .gitignore ├── AUTHORS ├── FECScraper.py ├── README ├── FECParser.py └── FECScraper.sql /.gitignore: -------------------------------------------------------------------------------- 1 | usersettings.py 2 | commidappend.py 3 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors: 2 | Christopher Schnaars (http://www.chrisschnaars.org/, twitter.com/chrisschnaars) 3 | Anthony DeBarros (http://www.anythonydebarros.com/, twitter.com/anthonydb) 4 | 5 | Contributors: 6 | Russell Clemings 7 | -------------------------------------------------------------------------------- /FECScraper.py: -------------------------------------------------------------------------------- 1 | # FEC Scraper 2 | # By Christopher Schnaars and Anthony DeBarros, USA TODAY 3 | # Developed with Python 2.7.2 4 | 5 | """ 6 | The purpose of this script is to scrape campaign finance reports 7 | from the Federal Election Commission (FEC) website for a specified 8 | group of committees. 9 | 10 | You are strongly encouraged to consult the documentation in README.txt 11 | before using this scraper so you'll understand what it does (and does 12 | not) do. In a nutshell, it captures only Form 3 filings by committees 13 | you specify below. 14 | 15 | Optionally, the script can interact with a database to help manage 16 | your downloaded data. Complete details can be found in README.txt. 17 | To do this, make sure the usedatabaseflag user variable is set to 1. 18 | 19 | You can specify up to three directories for various files: 20 | * savedir: This is where scraped files will be saved. 21 | * reviewdir: This is a directory where you can house files that you have not 22 | imported into your database because the data requires cleanup before it 23 | can be successfully imported. This script uses this directory only to look 24 | for files that previously have been downloaded. No files in this directory 25 | will be altered, and no new files will be saved here. 26 | * processeddir: Similarly, you can put files you've already imported 27 | into a database in this directory. As with reviewdir, the script will use 28 | this directory only to look for files that previously have been downloaded. 29 | It will not alter files in this directory or save new files here. 30 | 31 | You'll find commented code below to show you how to explicitly 32 | download filings for a particular committee. 33 | """ 34 | 35 | # User variables 36 | 37 | # Try to import your user settings or set them explicitly. The database 38 | # connection string will be ignored if database integration is disabled. 39 | try: 40 | exec(open('usersettings.py').read()) 41 | except: 42 | maindir = 'C:\\data\\Python\\FEC\\' 43 | connstr = 'DRIVER={SQL Server};SERVER=;DATABASE=FEC;UID=;PWD=;' 44 | 45 | # Directories: You can edit these to customize file locations. 46 | savedir = maindir + 'Import\\' 47 | reviewdir = maindir + 'Review\\' 48 | processeddir = maindir + 'Processed\\' 49 | 50 | # Set this flag to 1 if you want the script to interact with a database. 51 | # Set it to 0 if the script should run independent of any database. 52 | # A database is used solely to look for committees and files that 53 | # previously have been downloaded. 54 | usedatabaseflag = 1 55 | 56 | # Import libraries 57 | import re, urllib, glob, os 58 | 59 | # Create lists to hold committee and file IDs 60 | commidlist = [] 61 | fileidlist = [] 62 | 63 | # Display start message 64 | print 'Compiling lists of FEC committees and previously downloaded files...' 65 | 66 | # Create database connection to fetch lists of committee IDs and file IDs already in the database 67 | # The code below works with SQL Server; see README for tips on connecting 68 | # to other database managers. 69 | if usedatabaseflag == 1: 70 | import pyodbc 71 | conn = pyodbc.connect(connstr) 72 | cursor = conn.cursor() 73 | 74 | # Execute stored procedure and populate list with committee IDs 75 | sql = 'EXEC usp_GetCommitteeIDs' 76 | for row in cursor.execute(sql): 77 | commidlist += row 78 | 79 | # Execute stored procedure and populate list with file IDs 80 | sql = 'EXEC usp_GetFileIDs' 81 | for row in cursor.execute(sql): 82 | fileidlist += row 83 | 84 | # Close database connection 85 | conn.close() 86 | 87 | # Add IDs for files in review directory 88 | for datafile in glob.glob(os.path.join(reviewdir, '*.fec')): 89 | fileidlist.append(datafile.replace(reviewdir, '')[:6]) 90 | 91 | # Add IDs for files in save directory 92 | for datafile in glob.glob(os.path.join(savedir, '*.fec')): 93 | fileidlist.append(datafile.replace(savedir, '')[:6]) 94 | 95 | # Add IDs for files in processed directory 96 | 97 | for datafile in glob.glob(os.path.join(processeddir, '*.fec')): 98 | fileidlist.append(datafile.replace(processeddir, '')[:6]) 99 | 100 | # Sort the fileid list 101 | fileidlist.sort() 102 | 103 | # If you need to add committee IDs for candidates or PACs for which 104 | # you've never previously downloaded data, you can do that here like this: 105 | try: 106 | for line in open('commidappend.txt', 'rb'): 107 | if len(line.strip()) == 9 and line.startswith('C'): 108 | commidlist.append(line.strip()) 109 | except: 110 | pass 111 | finally: 112 | # commidlist.append('C00431445') # Obama for America 113 | # commidlist.append('C00500587') # RickPerry.org Inc. 114 | # commidlist.append('C00431171') # Romney for President Inc. 115 | pass 116 | 117 | # Begin scrape 118 | print 'Done!\n' 119 | print 'Initializing FEC scrape...' 120 | print 'Fetching data for ' + str(len(commidlist)) + ' committees.\n' 121 | 122 | # Set up a list to house all available file IDs 123 | filing_numbers = [] 124 | 125 | # Set a regular expression to match six-digit numbers 126 | regex = re.compile(r'[0-9]{6}') 127 | 128 | # For each committee id, open the page and read its HTML 129 | for x in commidlist: 130 | print 'Searching files for ' + x + '.' 131 | url = "http://query.nictusa.com/cgi-bin/dcdev/forms/" + x + "/" 132 | html = urllib.urlopen(url) 133 | response = html.read() 134 | 135 | # For each line in the HTML, look for "Form F3" and a six-digit number 136 | # and build a list 137 | for line in response.splitlines(): 138 | if re.search("Form F3", line) and re.search(regex, line): 139 | filing_numbers += re.findall(regex, line) 140 | 141 | filing_numbers.sort() 142 | 143 | # Create another list for file IDs to download 144 | downloadlist = [] 145 | 146 | # Compile list of file IDs that have not been downloaded previously 147 | for x in filing_numbers: 148 | if fileidlist.count(x) == 0: 149 | downloadlist.append(x) 150 | 151 | # File search completed 152 | print '\nFile search completed. Beginning download...\n' 153 | 154 | # For each retrieved filing number, download and save the files. 155 | for y in downloadlist: 156 | filename = y + ".fec" 157 | print 'Downloading ' + filename + '.' 158 | url2 = "http://query.nictusa.com/dcdev/posted/" + filename 159 | urllib.urlretrieve(url2, savedir + filename) 160 | 161 | # Display completion message 162 | print 'File download complete!' 163 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | FEC Scraper/FEC Parser: 2 | ----------------------- 3 | By Christopher Schnaars and Anthony DeBarros, USA TODAY 4 | Developed with Python 2.7.2 5 | 6 | 7 | 8 | Contents: 9 | --------- 10 | 1 - What's in the box? 11 | 2 - Requirements 12 | 3 - Notes about FEC data 13 | 4 - What is FEC Scraper? 14 | 5 - What is FEC Parser? 15 | 6 - What don't FEC Scraper and FEC Parser do? 16 | 7 - How to incorporate a database manager 17 | 8 - Directories 18 | 19 | 20 | 21 | 1 - What's in the box? 22 | ---------------------- 23 | FEC Scraper and FEC Parser are separate Python scripts that work together to 24 | download and parse data from the Federal Election Commission (FEC) provided in 25 | ASCII-28 delimited format. Optionally, you can enable integration with a 26 | database manager (SQL Server by default) to help you import the data and 27 | maintain database integrity. The scripts can handle hundreds or even thousands 28 | of files at once. The end result is eight to 11 tab-delimited text files 29 | housing cleaned-up data ready for easy import into a database manager or 30 | spreadsheet program. 31 | 32 | On the github site, you'll find a file called FECScraper.sql, which contains 33 | all the scripts you need to create tables and all other necessary database 34 | objects. If you are using a database manager other than SQL Server, you can 35 | use the schema contained in FECScraper.sql to build tables on a different RDMS. 36 | 37 | 38 | 39 | 2 - Requirements 40 | ---------------- 41 | If you want to enable functionality that integrates FEC Scraper and FEC Parser 42 | with a database manager, you'll need a library to connect to a database manager 43 | of your choice, if you don't use the SQLite functionality baked into Python. 44 | Examples: 45 | * pyodbc (SQL Server, http://code.google.com/p/pyodbc/downloads/list) 46 | * mySQLdb (mySQL, http://mysql-python.sourceforge.net) 47 | * psycopg2 (PostgreSQL, http://initd.org/psycopg/download/) 48 | 49 | Otherwise, the scripts just use standard libraries included with Python. These 50 | scripts were built in Python 2.7.2. 51 | 52 | 53 | 54 | 3 - Notes about FEC data 55 | ------------------------ 56 | Every candidate or organization that has to file reports with the FEC is 57 | assigned a committee ID number. FEC Scraper will download all Form 3 filings 58 | for each committe you specify, including Forms 3A, 3N, 3PA, 3PN, 3XA and 3XN. 59 | FEC Parser will churn through the data housed in these files and output 60 | standardized, tab-delimited text files for easy import. 61 | 62 | The Form 3 data files include monthly, quarterly and annual reports housing 63 | itemized contributions, expenditures and loans, among other types of 64 | information, so they probably contain everything you need. These reports are 65 | required by the FEC for all PACs and other political organizations as well 66 | as candidates for President and the House of Representatives (but not the 67 | Senate, where members still engage in the archaic process of filing their 68 | reports on paper to hide contributors and expenditures). 69 | 70 | As of this writing, the FEC offers data files in both comma and ASCII-28 71 | delimited formats. Because of inherent problems with .csv files (namely, commas 72 | in the data itself), FEC Scraper uses the ASCII-28 delimited format. This ASCII 73 | code is obscure and unlikely to show up in your data. 74 | 75 | Each data file contains two (and sometimes three) header rows. Among other 76 | information, these header rows specify the header version used by the data 77 | file. FEC Scraper downloads all Form 3 filings regardless of the header 78 | version, but FEC Parser supports only header versions 6.4, 7.0 and 8.0. Data 79 | files that utilize other header versions are moved to the Review directory and 80 | are not processed. 81 | 82 | Please note that as of this writing, if a data file contains a third header 83 | row, that row is ignored. A third header row occurs when data is included for 84 | Column C on 30G reports. You can see what that form looks like at: 85 | http://www.fec.gov/pdf/forms/fecfrm3post.pdf 86 | 87 | The script also does not yet handle Schedule H records, which sometimes occur 88 | on Form F3X. Support for this data will be added in an upcoming release. For 89 | what it's worth, processing all data for more than 250 PACs and all candidates 90 | for President and the House of Represenatives yielded just under 50 data rows, 91 | so this issue is minimal. All Schedule H data rows presently are saved to 92 | the Review file. 93 | 94 | 95 | 96 | 4 - What is FEC Scraper? 97 | ------------------------ 98 | FEC Scraper is a Python script you can run to find and download campaign 99 | finance filings from the Federal Election Commission website for specified 100 | committees, including candidates for president and the House of Representatives 101 | as well as Super PACs and other organizations. 102 | 103 | FEC Scraper is most powerful when you take advantage of its ability to interact 104 | with a database manager. When this functionality is enabled (by setting the 105 | usedatabaseflag variable to 1), the script will retrieve a list of committees 106 | that already exist in the database as well as all files housed in the database, 107 | then go to the FEC website to look for and scrape new filings for those 108 | committees. Reports already housed in the database will not be downloaded. 109 | 110 | You also can specify a "Processed" directory. FEC Parser will move files that 111 | have been parsed successfully to this directory, and FEC Scraper will look in 112 | this directory to determine whether a data file previously has been imported. 113 | This helps ensure that even if the script doesn't interact with a database 114 | manager, you can avoid importing the same file more than once as long as you 115 | don't delete the processed files. 116 | 117 | (Development note: In a future version, we could have FEC Parser create and 118 | modify a text file housing a list of all Image IDs that have been processed.) 119 | 120 | If you don't interact with a database or if you want to download reports for a 121 | committe that does not exist in the database, you must specify in the script 122 | which committees you want to scrape. This is handled in a Try block near line 123 | 100 of the code. There are two ways to specify committees: 124 | 125 | First, the code will look for a text file called commidappend.txt. You can 126 | specify a list of committees (one per line) in the file. Don't use commas 127 | or any other separator, and make sure the committe IDs begin with a capital C. 128 | The file should look something like this: 129 | C00431445 130 | C00500587 131 | C00431171 132 | 133 | Additionally, you can write code in the Finally block to append the commidlist 134 | list directly. Examples: 135 | commidlist.append('C00431445') # Obama for America 136 | commidlist.append('C00500587') # RickPerry.org Inc. 137 | commidlist.append('C00431171') # Romney for President Inc. 138 | 139 | 140 | 141 | 5 - What is FEC Parser? 142 | ----------------------- 143 | FEC Parser is a Python script that converts ASCII-28 delimited data files from 144 | the FEC into standard tab-delimited text files that easily can be imported into 145 | any database manager or spreadsheet program. 146 | 147 | When you download a Form 3 filing from the FEC, the data file contains two or 148 | three header rows at the top of the file, followed by data housed on eight 149 | separate forms (Schedules A, B, C, C1, C2, D and E and a long-text form). This 150 | data is in no particular order, and each form has different numbers of columns, 151 | and different column headings, making import tricky. Additionally, the FEC 152 | routinely adds and removes columns. 153 | 154 | If FEC Parser finds a file that is not a Form 3 filing (see the "Notes about 155 | FEC data" section above), the file will be moved to a Review directory you 156 | specify. In some cases, FEC Parser will append to the filename a brief 157 | explanation of why the file was not parsed. 158 | 159 | FEC Parser will go through all files with an .fec extension in whatever 160 | directory you specify and output eight tab-delimited text files: one for each 161 | schedule form. FEC Parser can process hundreds or even thousands of files at 162 | once. Each data row will be prepended with the FEC's unique ID for that file 163 | (called the ImageID) to create parent-child relationships between a header and 164 | each data row. 165 | 166 | Any tabs contained in the data are converted to spaces during parsing. 167 | 168 | If you implement the functionality that allows FEC Parser to interact with a 169 | database manager, it will check to make sure each report has not previously 170 | been imported into the database. If not, it will load the header rows into 171 | parent tables. 172 | 173 | If database functionality is disabled (the default behavior), FEC Parser will 174 | create three additional text files for the F3, F3P and F3X headers. 175 | 176 | FEC Parser presently supports only header versions 6.4, 7.0 and 8.0. Data files 177 | that utilize other header versions are moved to the Review directory and are 178 | not processed. 179 | 180 | Please note that due to the inherent messiness of FEC data (particularly 181 | problems with missing or excess column delimiters, FEC Parser will add 182 | delimiters to data rows that do not have the correct number of columns and 183 | remove excess delimiters when there are too many. If FEC Parser finds data in 184 | any excess columns, that row is instead written to the review file so no data 185 | is lost. 186 | 187 | This could cause data to be written to the wrong column if excess or missing 188 | delimiters occur anywhere other than the end of a data row. I've tested the 189 | data extensively, however, and as of this writing, I have never found a problem 190 | other than at the end of a data row. 191 | 192 | 193 | 194 | 6 - What don't FEC Scraper and FEC Parser do? 195 | --------------------------------------------- 196 | FEC Scraper downloads only Form 3 filings. (For more information about Form 3 197 | and other filings, see the "Notes about FEC data" section above.) All other 198 | filings are ignored. 199 | 200 | Additionally, FEC Scraper does not download data for committees you don't 201 | specify. For the script to download filings for a particular committee you must 202 | do one of two things: 203 | * You must specify the committee directly in the code (commented-out examples 204 | of how to do this are included in the script). 205 | * You must enable database integration (by setting usedatabaseflag to 1) AND 206 | you must have data for that committee in the database. (When database 207 | integration is enabled, FEC Scraper will get a list of existing committees from 208 | the database and automatically download all new filings for them.) 209 | 210 | If you have database integration enabled, FEC Parser will load the header rows 211 | from the data files into your database. Otherwise, the script does not load any 212 | data into your database. You must manually import the data files after the 213 | script runs. 214 | 215 | Additionally, FEC Parser handles only Form 3 filings, and those filings must 216 | have header version 6.4, 7.0 or 8.0. All other form types and all Form 3 217 | filings with other header versions are moved to the Review directory and are 218 | not processed. 219 | 220 | 221 | 222 | 7 - How to incorporate a database with FEC Scraper 223 | --------------------------------------------------- 224 | Near the top of the code for both FEC Scraper and FEC Parser, in the User 225 | Variables section, you can set the usedatabaseflag variable to 1 if you want 226 | the script to interact with a datatbase manager and 0 if you want the script to 227 | run independent of a database. 228 | 229 | Both scripts include code to import the pyodbc module 230 | (http://code.google.com/p/pyodbc/downloads/list) to integrate them with a SQL 231 | Server database. If you want to use a different database manager, you will need 232 | to modify the code to use a different library. Here are a few suggestions: 233 | * mySQL: MySQLdb module (http://mysql-python.sourceforge.net) 234 | * PostgreSQL: psycopg2 module (http://initd.org/psycopg/download/) 235 | 236 | For the default SQL Server code, you will need to specify the server and the 237 | name of the database (if you've named it something other than FEC) in the 238 | connection string. If necessary, you also can specify a username (UID) and 239 | password (PWD). 240 | 241 | When FEC Scraper runs with database integration enabled, it calls two stored 242 | procedures that create lists of Committee IDs and Image IDs that already exist 243 | in the database. FEC Scraper uses these lists to determine what committees to 244 | scrape and what files do not need to be downloaded. The script also will not 245 | download any files that already exist in the processed or review directories. 246 | 247 | When FEC Parser runs with databse integration enabled, it will check the 248 | database each time it processes a file to make sure that Image ID does not 249 | already exist in the database. The user will be alerted any time it finds a 250 | duplicate file, and that file will be omitted from the text files created 251 | by the script. Additionally, the header rows are loaded into the 252 | database for you. 253 | 254 | When database integration is disabled, FEC Parser will output the header rows 255 | to an additional three data files that you can import manually. 256 | 257 | The FECScraper.sql file contains all the SQL Server scripts you need to create 258 | the necessary tables, stored procedures and other database objects. You can use 259 | this code to create similar objects for other database managers. 260 | 261 | 262 | 263 | 8 - Directories 264 | --------------- 265 | You can specify up to four directories for various files: 266 | * savedir: This is where FEC Scraper saves files. FEC Parser will process all 267 | .fed files housed in this directory. 268 | * reviewdir: FEC Scraper gets a list of files housed in this directory and 269 | uses this list to avoid downloading previously downloaded files. 270 | FEC Parser moves all files that cannot be processed to this directory, such 271 | as files that are not Form 3 or use an unsupported header version. For data 272 | rows that are in a valid file but can't be parsed, FEC Parser writes those data 273 | rows to a single timestamped review file and saves that file here. 274 | No files in this directory are altered by either script, though FEC Parser 275 | may append to the file name a brief description of why the file could not be 276 | parsed. 277 | * processeddir: FEC Scraper gets a list of files housed in this directory and 278 | uses this list to avoid downloading previously downloaded files. 279 | FEC Parser moves all valid, processed files from the save directory to this 280 | directory. 281 | * outputdir: FEC Scraper does not use this directory. FEC Parser saves the 282 | time-stamped tab-delimited data files it creates in this directory. 283 | 284 | -------------------------------------------------------------------------------- /FECParser.py: -------------------------------------------------------------------------------- 1 | # FEC Parser 2 | # By Christopher Schnaars, USA TODAY 3 | # Developed with Python 2.7.2 4 | 5 | """ 6 | The purpose of this script is to parse ASCII-28 delimited text files 7 | from the Federal Election Commission (FEC) containing campaign 8 | contribution, expenditure, loan and other data from Form 3 reports filed 9 | by candidate committees, political action committees (PACs) and 10 | other organizations. 11 | 12 | If you enable the script's database functionality, header rows are added 13 | to Form F3 tables in a database mamager. 14 | 15 | Regardless of whether you use database integration, the Image ID for 16 | each file (the unique ID assigned to each file by the FEC) is prepended 17 | to each data row. 18 | 19 | This script presently supports only header versions 6.4, 7.0 and 8.0. 20 | Files with unsupported headers are moved to the review directory. 21 | 22 | Child rows with unrecognizable codes in the first (FormType) column 23 | are saved to a timestamped "review" file saved in the review directory. 24 | 25 | For complete documentation, see the README file. 26 | """ 27 | 28 | # User variables 29 | 30 | # Try to import your user settings or set them explicitly. The database 31 | # connection string will be ignored if database integration is disabled. 32 | try: 33 | exec(open('usersettings.py').read()) 34 | except: 35 | maindir = 'C:\\data\\Python\\FEC\\' 36 | connstr = 'DRIVER={SQL Server};SERVER=;DATABASE=FEC;UID=;PWD=;' 37 | 38 | # You can alter these to customize file locations 39 | sourcedir = maindir + 'Import\\' 40 | destdir = maindir + 'Processed\\' 41 | outputdir = maindir + 'Output\\' 42 | reviewdir = maindir + 'Review\\' 43 | 44 | # Database integration flag 45 | # Set to 1 to integrate with your database. 46 | # Set to 0 to disable this functionality 47 | usedatabaseflag = 1 48 | 49 | # Script variables 50 | delimiter = chr(28) 51 | 52 | # Import needed libraries 53 | import os, glob, time, linecache, shutil 54 | 55 | # Create text files for data dump 56 | try: 57 | timestamp = time.strftime('%Y_%m_%d_%H_%M_%S') 58 | scheduleafile = outputdir + 'ScheduleAImport_' + timestamp + '.txt' 59 | schedulebfile = outputdir + 'ScheduleBImport_' + timestamp + '.txt' 60 | schedulecfile = outputdir + 'ScheduleCImport_' + timestamp + '.txt' 61 | schedulec1file = outputdir + 'ScheduleC1Import_' + timestamp + '.txt' 62 | schedulec2file = outputdir + 'ScheduleC2Import_' + timestamp + '.txt' 63 | scheduledfile = outputdir + 'ScheduleDImport_' + timestamp + '.txt' 64 | scheduleefile = outputdir + 'ScheduleEImport_' + timestamp + '.txt' 65 | textfile = outputdir + 'TextImport_' + timestamp + '.txt' 66 | reviewfile = reviewdir + 'Review_' + timestamp + '.txt' 67 | 68 | sched_a_file = open(scheduleafile, 'w') 69 | sched_b_file = open(schedulebfile, 'w') 70 | sched_c_file = open(schedulecfile, 'w') 71 | sched_c1_file = open(schedulec1file, 'w') 72 | sched_c2_file = open(schedulec2file, 'w') 73 | sched_d_file = open(scheduledfile, 'w') 74 | sched_e_file = open(scheduleefile, 'w') 75 | text_file = open(textfile, 'w') 76 | review_file = open(reviewfile, 'w') 77 | 78 | # Create column headers 79 | scheduleaheaderstring = 'ParentType\tImageId\tFormType\tCommID\tTransID\tBackRefTransID\tBackRefSchedName\t' \ 80 | 'EntityType\tContOrgName\tContLastName\tContFirstName\tContMidName\t' \ 81 | 'ContPrefix\tContSuffix\tContAddress1\tContAddress2\tContCity\tContState\t' \ 82 | 'ContZip\tElecCode\tElecOtherDesc\tstrContDate\tContAmount\tContAggregate\t' \ 83 | 'ContPurposeCode\tContPurposeDesc\tContEmployer\tContOccupation\t' \ 84 | 'DonorCommFECID\tDonorCommName\tDonorCandFECID\tDonorCandLastName\t' \ 85 | 'DonorCandFirstName\tDonorCandMidName\tDonorCandPrefix\tDonorCandSuffix\t' \ 86 | 'DonorCandOffice\tDonorCandState\tDonorCandDist\tConduitName\t' \ 87 | 'ConduitAddress1\tConduitAddress2\tConduitCity\tConduitState\tConduitZip\t' \ 88 | 'MemoCode\tMemoText\n' 89 | schedulebheaderstring = 'ParentType\tImageId\tFormType\tFilerCommID\tTransID\tBackRefTransID\tBackRefSchedName\t' \ 90 | 'EntityType\tPayeeOrgName\tPayeeLastName\tPayeeFirstName\tPayeeMidName\t' \ 91 | 'PayeePrefix\tPayeeSuffix\tPayeeAddress1\tPayeeAddress2\tPayeeCity\t' \ 92 | 'PayeeState\tPayeeZip\tElecCode\tElecOtherDesc\tstrExpDate\tExpAmount\t' \ 93 | 'SemiAnnRefundedBundledAmt\tExpPurpCode\tExpPurpDesc\tCatCode\tBenCommFECID\t' \ 94 | 'BenCommName\tBenCandFECID\tBenCandLastName\tBenCandFirstName\tBenCandMidName\t' \ 95 | 'BenCandPrefix\tBenCandSuffix\tBenCandOffice\tBenCandState\tBenCandDist\t' \ 96 | 'ConduitName\tConduitAddress1\tConduitAddress2\tConduitCity\tConduitState\t' \ 97 | 'ConduitZip\tMemoCode\tMemoText\n' 98 | schedulecheaderstring = 'ParentType\tImageId\tFormType\tFilerCommID\tTransID\tRectLineNbr\tEntityType\t' \ 99 | 'LenderOrgName\tLenderLastName\tLenderFirstName\tLenderMidName\t' \ 100 | 'LenderPrefix\tLenderSuffix\tLenderAddress1\tLenderAddress2\t' \ 101 | 'LenderCity\tLenterState\tLenderZip\tElecCod\tElecOtherDesc\t' \ 102 | 'LoanAmt\tLoanPymtToDate\tLoanBal\tstrLoanIncurredDate\t' \ 103 | 'strLoanDueDate\tLoanIntRate\tLoanSecuredFlag\tLoanPersFundsFlag\t' \ 104 | 'LenderCommID\tLenderCandID\tLenderCandLastName\tLenderCandFirstName\t' \ 105 | 'LenderCandMidName\tLenderCandPrefix\tLenderCandSuffix\tLenderCandOffice\t' \ 106 | 'LenderCandState\tLenderCandDist\tMemoCode\tMemoText\n' 107 | schedulec1headerstring = 'ParentType\tImageId\tFormType\tFilerCommID\tTransID\tBackRefTransID\t' \ 108 | 'LenderOrgName\tLenderAddress1\tLenderAddress2\tLenderCity\t' \ 109 | 'LenderState\tLenderZip\tLoanAmt\tLoanIntRate\tstrLoanIncurredDate\t' \ 110 | 'strLoanDueDate\tA1_LoanRestructuredFlag\tA2_strOrigLoanIncurredDate\t' \ 111 | 'B1_CreditAmtThisDraw\tB2_TotBalance\tC_OthersLiableFlag\t' \ 112 | 'D_CollateralFlag\tD1_CollateralDescription\tD2_CollateralValue\t' \ 113 | 'D3_PerfectedInterestFlag\tE1_FutureIncomeFlag\tE2_FutureIncomeDesc\t' \ 114 | 'E3_EstimatedValue\tE4_strDepositoryAcctEstablishedDate\tE5_AcctLocName\t' \ 115 | 'E6_AcctAddress1\tE7_AcctAddress1\tE8_AcctCity\tE9_State\tE10_Zip\t' \ 116 | 'E11_strDepositAcctAuthDate\tF_LoanBasisDesc\tG_TreasLastName\t' \ 117 | 'G_TreasFirstName\tG_TreasMidName\tG_TreasPrefix\tG_TreasSuffix\t' \ 118 | 'G_strDateSigned\tH_AuthorizedLastName\tH_AuthorizedfirstName\t' \ 119 | 'H_AuthorizedMidName\tH_AuthorizedPrefix\tH_AuthorizedSuffix\t' \ 120 | 'H_AuthorizedTitle\tH_strDateSigned\n' 121 | schedulec2headerstring = 'ParentType\tImageId\tFormType\tFilerCommID\tTransID\tBackRefTransID\t' \ 122 | 'GuarLastName\tGuarFirstName\tGuarMidName\tGuarPrefix\t' \ 123 | 'GuarSuffix\tGuarAddress1\tGuarAddress2\tGuarCity\tGuarState\t' \ 124 | 'GuarZip\tGuarEmployer\tGuarOccupation\tGuarAmt\n' 125 | scheduledheaderstring = 'ParentType\tImageId\tFormType\tCommID\tTransID\tEntityType\tCredOrgName\t' \ 126 | 'CredLastName\tCredFirstName\tCredMidName\tCredPrefix\t' \ 127 | 'CredSuffix\tCredAddress1\tCredAddress2\tCredCity\tCredState\t' \ 128 | 'CredZip\tDebtPurpose\tBegBal_Prd\tIncurredAmt_Prd\tPaymtAmt_Prd\t' \ 129 | 'BalanceAtClose_Prd\n' 130 | scheduleeheaderstring = 'ParentType\tImageId\tFormType\tFilerCommID\tTransID\tBackRefTransID\t' \ 131 | 'BackRefSchedName\tEntityType\tPayeeOrgName\tPayeeLastName\t' \ 132 | 'PayeeFirstName\tPayeeMidName\tPayeePrefix\tPayeeSuffix\t' \ 133 | 'PayeeAddress1\tPayeeAddress2\tPayeeCity\tPayeeState\tPayeeZip\t' \ 134 | 'ElecCode\tElecOtherDesc\tstrExpDate\tExpAmount\tCalYTD\t' \ 135 | 'ExpPurpCode\tExpPurpDesc\tCatCode\tPayeeCommFECID\tSuppOppCode\t' \ 136 | 'SuppOppCandID\tSuppOppCandLastName\tSuppOppCandFirstName\t' \ 137 | 'SuppOppCandMidName\tSuppOppCandPrefix\tSuppOppCandSuffix\t' \ 138 | 'SuppOppCandOffice\tSuppOppCandState\tSuppOppCandDist\t' \ 139 | 'CompLastName\tCompFirstName\tCompMidName\tCompPrefix\tCompSuffix\t' \ 140 | 'strDateSigned\tMemoCode\tMemoText\n' 141 | textheaderstring = 'ParentType\tImageId\tRecType\tCommID\tTransID\tBackRefTransID\tBackRefFormName\tFullText\n' 142 | 143 | # Write headers to output files 144 | sched_a_file.write(scheduleaheaderstring) 145 | sched_b_file.write(schedulebheaderstring) 146 | sched_c_file.write(schedulecheaderstring) 147 | sched_c1_file.write(schedulec1headerstring) 148 | sched_c2_file.write(schedulec2headerstring) 149 | sched_d_file.write(scheduledheaderstring) 150 | sched_e_file.write(scheduleeheaderstring) 151 | text_file.write(textheaderstring) 152 | 153 | # Import appropriate library if database integration is enabled. 154 | # Otherwise, create text files to house headers. 155 | if usedatabaseflag == 1: 156 | 157 | # import necessary library 158 | import pyodbc # SQL Server 159 | 160 | else: 161 | formf3headerfile = outputdir + 'FormF3Headers_' + timestamp + '.txt' 162 | formf3pheaderfile = outputdir + 'FormF3PHeaders_' + timestamp + '.txt' 163 | formf3xheaderfile = outputdir + 'FormF3XHeaders_' + timestamp + '.txt' 164 | 165 | form_f3_file = open(formf3headerfile, 'w') 166 | form_f3p_file = open(formf3pheaderfile, 'w') 167 | form_f3x_file = open(formf3xheaderfile, 'w') 168 | 169 | formf3headerstring = 'ImageID\tFormType\tCommID\tCommName\t' \ 170 | 'AddressChange\tCommAddress1\tCommAddress2\tCommCity\tCommState\t' \ 171 | 'CommZip\tElecState\tElecDist\tReptCode\tElecCode\tstrElecDate\t' \ 172 | 'StateOfElec\tstrCovgFromDate\tstrCovgToDate\tTreasLastName\t' \ 173 | 'TreasFirstName\tTreasMidName\tTreasPrefix\tTreasSuffix\tstrDateSigned\t' \ 174 | 'Line6a_TotalContribs_Prd\tLine6b_TotalContribRefunds_Prd\t' \ 175 | 'Line6c_NetContribs_Prd\tLine7a_TotOpExps_Prd\tLine7b_TotOffsetToOpExps_Prd\t' \ 176 | 'Line7c_NetOpExps_Prd\tLine8_CashOnHandAtClose_Prd\tLine9_DebtsTo_Prd\t' \ 177 | 'Line10_DebtsBy_Prd\tLine11a1_IndivsItemized_Prd\tLine11a2_IndivsUnitemized_Prd\t' \ 178 | 'Line11a3_IndivsContribTotal_Prd\tLine11b_PolPtyComms_Prd\tLine11c_OtherPACs_Prd\t' \ 179 | 'Line11d_Candidate_Prd\tLine11e_TotalContribs_Prd\tLine12_TransfersFrom_Prd\t' \ 180 | 'Line13a_LoansByCand_Prd\tLine13b_OtherLoans_Prd\tLine13c_TotLoans_Prd\t' \ 181 | 'Line14_OffsetsToOpExps_Prd\tLine15_OtherReceipts_Prd\tLine16_TotReceipts_Prd\t' \ 182 | 'Line17_OpExps_Prd\tLine18_TransToOtherComms_Prd\tLine19a_LoanRepaymts_Cand_Prd\t' \ 183 | 'Line19b_LoanRepaymts_Other_Prd\tLine19c_TotLoanRepaymts_Prd\t' \ 184 | 'Loan20a_IndivRefunds_Prd\tLine20b_PolPartyCommRefunds_Prd\t' \ 185 | 'Line20c_OtherPolCommRefunds_Prd\tLine20d_TotContRefunds_Prd\t' \ 186 | 'Line21_OtherDisb_Prd\tLine22_TotDisb_Prd\tLine23_CashBegin_Prd\t' \ 187 | 'Line24_TotReceipts_Prd\tLine25_Subtotal\tLine26_TotDisbThisPrd_Prd\t' \ 188 | 'Line27_CashAtClose_Prd\tLine6a_TotalContribs_Tot\t' \ 189 | 'Line6b_TotalContribRefunds_Tot\tLine6c_NetContribs_Tot\tLine7a_TotOpExps_Tot\t' \ 190 | 'Line7b_TotOffsetToOpExps_Tot\tLine7c_NetOpExps_Tot\t' \ 191 | 'Line11a1_IndivsItemized_Tot\tLine11a2_IndivsUnitemized_Tot\t' \ 192 | 'Line11a3_IndivsContribTotal_Tot\tLine11b_PolPtyComms_Tot\t' \ 193 | 'Line11c_OtherPACs_Tot\tLine11d_Candidate_Tot\tLine11e_TotalContribs_Tot\t' \ 194 | 'Line12_TransfersFrom_Tot\tLine13a_LoansByCand_Tot\tLine13b_OtherLoans_Tot\t' \ 195 | 'Line13c_TotLoans_Tot\tLine14_OffsetsToOpExps_Tot\tLine15_OtherReceipts_Tot\t' \ 196 | 'Line16_TotReceipts_Tot\tLine17_OpExps_Tot\tLine18_TransToOtherComms_Tot\t' \ 197 | 'Line19a_LoanRepaymts_Cand_Tot\tLine19b_LoanRepaymts_Other_Tot\t' \ 198 | 'Line19c_TotLoanRepaymts_Tot\tLoan20a_IndivRefunds_Tot\t' \ 199 | 'Line20b_PolPartyCommRefunds_Tot\tLine20c_OtherPolCommRefunds_Tot\t' \ 200 | 'Line20d_TotContRefunds_Tot\tLine21_OtherDisb_Tot\tLine22_TotDisb_Tot\n' 201 | formf3pheaderstring = 'ImageID\tFormType\tCommID\tCommName\t' \ 202 | 'AddressChange\tCommAddress1\tCommAddress2\tCommCity\tCommState\t' \ 203 | 'CommZip\tActivityPrim\tActivityGen\tReptCode\tElecCode\t' \ 204 | 'strElecDate\tElecState\tstrFromDate\tstrToDate\tTreasLastName\t' \ 205 | 'TreasFirstName\tTreasMidName\tTreasPrefix\tTreasSuffix\t' \ 206 | 'strDateSigned\tLine6_CashBegin\tLine7_TotReceipts\t' \ 207 | 'Line8_Subtotal\tLine9_TotalDisb\tLine10_CashClose\t' \ 208 | 'Line11_DebtsTo\tLine12_DebtsBy\tLine13_ExpendsSubToLimits\t' \ 209 | 'Line14_NetContribs\tLine15_NetOpExps\tLine16_FedFunds_Prd\t' \ 210 | 'Line17a1_IndivsItemzd_Prd\tLine17a2_IndivsUnItemzd_Prd\t' \ 211 | 'Line17a3_IndContTot_Prd\tLine17b_PolPartyComms_Prd\t' \ 212 | 'Line17c_OtherPACs_Prd\tLine17d_Candidate_Prd\t' \ 213 | 'Line17e_TotContribs_Prd\tLine18_TransfersFrom_Prd\t' \ 214 | 'Line19a_CandLoans_Prd\tLine19b_OtherLoans_Prd\t' \ 215 | 'Line19c_TotLoans_Prd\tLine20a_Operating_Prd\t' \ 216 | 'Line20b_Fundraising_Prd\tLine20c_LegalAcctg_Prd\t' \ 217 | 'Line20d_TotExpOffsets_Prd\tLine21_OtherReceipts_Prd\t' \ 218 | 'Line22_TotReceipts_Prd\tLine23_OpExpends_Prd\t' \ 219 | 'Line24_TransToOtherComms_Prd\tLine25_FundraisingDisbursed_Prd\t' \ 220 | 'Line26_ExemptLegalAcctgDisb_Prd\tLine27a_CandRepymts_Prd\t' \ 221 | 'Line27b_OtherRepymts_Prd\tLine27c_TotLoanRepymts_Prd\t' \ 222 | 'Line28a_IndivRefunds_Prd\tLine28b_PolPartyCommRefunds_Prd\t' \ 223 | 'Line28c_OtherPolCommRefunds_Prd\tLine28d_TotalContRefunds_Prd\t' \ 224 | 'Line29_OtherDisb_Prd\tLine30_TotDisb_Prd\t' \ 225 | 'Line31_ItemsToLiq_Prd\tAllocAlabama_Prd\tAllocAlaska_Prd\t' \ 226 | 'AllocArizona_Prd\tAllocArkansas_Prd\tAllocCalifornia_Prd\t' \ 227 | 'AllocColorado_Prd\tAllocConnecticut_Prd\tAllocDelaware_Prd\t' \ 228 | 'AllocDistCol_Prd\tAllocFlorida_Prd\tAllocGeorgia_Prd\t' \ 229 | 'AllocHawaii_Prd\tAllocIdaho_Prd\tAllocIllinois_Prd\t' \ 230 | 'AllocIndiana_Prd\tAllocIowa_Prd\tAllocKansas_Prd\t' \ 231 | 'AllocKentucky_Prd\tAllocLouisiana_Prd\tAllocMaine_Prd\t' \ 232 | 'AllocMaryland_Prd\tAllocMassachusetts_Prd\tAllocMichigan_Prd\t' \ 233 | 'AllocMinnesota_Prd\tAllocMississippi_Prd\tAllocMissouri_Prd\t' \ 234 | 'AllocMontana_Prd\tAllocNebraska_Prd\tAllocNevada_Prd\t' \ 235 | 'AllocNewHampshire_Prd\tAllocNewJersey_Prd\tAllocNewMexico_Prd\t' \ 236 | 'AllocNewYork_Prd\tAllocNorthCarolina_Prd\t' \ 237 | 'AllocNorthDakota_Prd\tAllocOhio_Prd\tAllocOklahoma_Prd\t' \ 238 | 'AllocOregon_Prd\tAllocPennsylvania_Prd\tAllocRhodeIsland_Prd\t' \ 239 | 'AllocSouthCarolina_Prd\tAllocSouthDakota_Prd\t' \ 240 | 'AllocTennessee_Prd\tAllocTexas_Prd\tAllocUtah_Prd\t' \ 241 | 'AllocVermont_Prd\tAllocVirginia_Prd\tAllocWashington_Prd\t' \ 242 | 'AllocWestVirginia_Prd\tAllocWisconsin_Prd\tAllocWyoming_Prd\t' \ 243 | 'AllocPuertoRico_Prd\tAllocGuam_Prd\tAllocVirginIslands_Prd\t' \ 244 | 'AllocStatesTotal_Prd\tLine16_FedFunds_Tot\t' \ 245 | 'Line17a1_IndivsItemzd_Tot\tLine17a2_IndivsUnItemzd_Tot\t' \ 246 | 'Line17a3_IndContTot_Tot\tLine17b_PolPartyComms_Tot\t' \ 247 | 'Line17c_OtherPACs_Tot\tLine17d_Candidate_Tot\t' \ 248 | 'Line17e_TotContribs_Tot\tLine18_TransfersFrom_Tot\t' \ 249 | 'Line19a_CandLoans_Tot\tLine19b_OtherLoans_Tot\t' \ 250 | 'Line19c_TotLoans_Tot\tLine20a_Operating_Tot\t' \ 251 | 'Line20b_Fundraising_Tot\tLine20c_LegalAcctg_Tot\t' \ 252 | 'Line20d_TotExpOffsets_Tot\tLine21_OtherReceipts_Tot\t' \ 253 | 'Line22_TotReceipts_Tot\tLine23_OpExpends_Tot\t' \ 254 | 'Line24_TransToOtherComms_Tot\tLine25_FundraisingDisbursed_Tot\t' \ 255 | 'Line26_ExemptLegalAcctgDisb_Tot\tLine27a_CandRepymts_Tot\t' \ 256 | 'Line27b_OtherRepymts_Tot\tLine27c_TotLoanRepymts_Tot\t' \ 257 | 'Line28a_IndivRefunds_Tot\tLine28b_PolPartyCommRefunds_Tot\t' \ 258 | 'Line28c_OtherPolCommRefunds_Tot\t' \ 259 | 'Line28d_TotalContRefunds_Tot\tLine29_OtherDisb_Tot\t' \ 260 | 'Line30_TotDisb_Tot\tAllocAlabama_Tot\tAllocAlaska_Tot\t' \ 261 | 'AllocArizona_Tot\tAllocArkansas_Tot\tAllocCalifornia_Tot\t' \ 262 | 'AllocColorado_Tot\tAllocConnecticut_Tot\tAllocDelaware_Tot\t' \ 263 | 'AllocDistCol_Tot\tAllocFlorida_Tot\tAllocGeorgia_Tot\t' \ 264 | 'AllocHawaii_Tot\tAllocIdaho_Tot\tAllocIllinois_Tot\t' \ 265 | 'AllocIndiana_Tot\tAllocIowa_Tot\tAllocKansas_Tot\t' \ 266 | 'AllocKentucky_Tot\tAllocLouisiana_Tot\tAllocMaine_Tot\t' \ 267 | 'AllocMaryland_Tot\tAllocMassachusetts_Tot\t' \ 268 | 'AllocMichigan_Tot\tAllocMinnesota_Tot\tAllocMississippi_Tot\t' \ 269 | 'AllocMissouri_Tot\tAllocMontana_Tot\tAllocNebraska_Tot\t' \ 270 | 'AllocNevada_Tot\tAllocNewHampshire_Tot\tAllocNewJersey_Tot\t' \ 271 | 'AllocNewMexico_Tot\tAllocNewYork_Tot\tAllocNorthCarolina_Tot\t' \ 272 | 'AllocNorthDakota_Tot\tAllocOhio_Tot\tAllocOklahoma_Tot\t' \ 273 | 'AllocOregon_Tot\tAllocPennsylvania_Tot\tAllocRhodeIsland_Tot\t' \ 274 | 'AllocSouthCarolina_Tot\tAllocSouthDakota_Tot\t' \ 275 | 'AllocTennessee_Tot\tAllocTexas_Tot\tAllocUtah_Tot\t' \ 276 | 'AllocVermont_Tot\tAllocVirginia_Tot\tAllocWashington_Tot\t' \ 277 | 'AllocWestVirginia_Tot\tAllocWisconsin_Tot\tAllocWyoming_Tot\t' \ 278 | 'AllocPuertoRico_Tot\tAllocGuam_Tot\tAllocVirginIslands_Tot\t' \ 279 | 'AllocStatesTotal_Tot\n' 280 | formf3xheaderstring = 'ImageID\tFormType\tCommID\t' \ 281 | 'CommName\tAddressChange\tCommAddress1\tCommAddress2\t' \ 282 | 'CommCity\tCommState\tCommZip\tReptCode\tElecCode\t' \ 283 | 'strElecDate\tElecState\tstrFromDate\tstrToDate\t' \ 284 | 'flgQualifiedComm\tTreasLastName\tTreasFirstName\t' \ 285 | 'TreasMidName\tTreasPrefix\tTreasSuffix\tstrDateSigned\t' \ 286 | 'Line6b_CashBegin_Prd\tLine6c_TotalRects_Prd\t' \ 287 | 'Line6d_CashBeginSubtotal_Prd\tLine7_TotDisbmts_Prd\t' \ 288 | 'Line8_CashOnHandAtClose_Prd\tLine9_DebtsTo_Prd\t' \ 289 | 'Line10_DebtsBy_Prd\tLine11a1_Itemized_Prd\t' \ 290 | 'Line11a2_Unitemized_Prd\tLine11a3_Total_Prd\t' \ 291 | 'Line11b_PolPtyComms_Prd\tLine11c_OtherPACs_Prd\t' \ 292 | 'Line11d_TotalContribs_Prd\tLine12_TransfersFrom_Prd\t' \ 293 | 'Line13_AllLoansRcvd_Prd\tLine14_LoanRepymtsRecv_Prd\t' \ 294 | 'Line15_OffsetsToOpExps_Refunds_Prd\t' \ 295 | 'Line16_RefundsOfFedContribs_Prd\t' \ 296 | 'Line17_OtherFedRects_Divds_Prd\t' \ 297 | 'Line18a_TransfersFromNonFedAcct_H3_Prd\t' \ 298 | 'Line18b_TransfersFromNonFed_LevinH5_Prd\t' \ 299 | 'Line18c_TotalNonFedTransfers_Prd\t' \ 300 | 'Line19_TotalReceipts_Prd\tLine20_TotalFedReceipts_Prd\t' \ 301 | 'Line21a1_FedShare_Prd\tLine21a2_NonFedShare_Prd\t' \ 302 | 'Line21b_OtherFedOpExps_Prd\tLine21c_TotOpExps_Prd\t' \ 303 | 'Line22_TransToOtherComms_Prd\t' \ 304 | 'Line23_ContribsToFedCandsOrComms_Prd\t' \ 305 | 'Line24_IndptExps_Prd\tLine25_CoordtdExpByPrtyComms_Prd\t' \ 306 | 'Line26_LoanRepayments_Prd\tLine27_LoansMade_Prd\t' \ 307 | 'Line28a_IndivRefunds_Prd\t' \ 308 | 'Line28b_PolPartyCommRefunds_Prd\t' \ 309 | 'Line28c_OtherPolCommRefunds_Prd\t' \ 310 | 'Line28d_TotalContRefunds_Prd\tLine29_OtherDisb_Prd\t' \ 311 | 'Line30a1_SharedFedActH6FedShare_Prd\t' \ 312 | 'Line30a2_SharedFedActH6NonFed_Prd\t' \ 313 | 'Line30b_NonAlloc100PctFedElecActivity_Prd\t' \ 314 | 'Line30c_TotFedElecActivity_Prd\tLine31_TotDisbmts_Prd\t' \ 315 | 'Line32_TotFedDisbmts_Prd\tLine33_TotContribs_Prd\t' \ 316 | 'Line34_TotContribRefunds_Prd\tLine35_NetContribs_Prd\t' \ 317 | 'Line36_TotFedOpExps_Prd\tLine37_OffsetsToOpExps_Prd\t' \ 318 | 'Line38_NetOpExps_Prd\tLine6b_CashBegin_Tot\tLine6b_Year\t' \ 319 | 'Line6c_TotalRects_Tot\tLine6d_CashBeginSubtotal_Tot\t' \ 320 | 'Line7_TotDisbmts_Tot\tLine8_CashOnHandAtClose_Tot\t' \ 321 | 'Line11a1_Itemized_Tot\tLine11a2_Unitemized_Tot\t' \ 322 | 'Line11a3_Total_Tot\tLine11b_PolPtyComms_Tot\t' \ 323 | 'Line11c_OtherPACs_Tot\tLine11d_TotalContribs_Tot\t' \ 324 | 'Line12_TransfersFrom_Tot\tLine13_AllLoansRcvd_Tot\t' \ 325 | 'Line14_LoanRepymtsRecv_Tot\t' \ 326 | 'Line15_OffsetsToOpExps_Refunds_Tot\t' \ 327 | 'Line16_RefundsOfFedContribs_Tot\t' \ 328 | 'Line17_OtherFedRects_Divds_Tot\t' \ 329 | 'Line18a_TransfersFromNonFedAcct_H3_Tot\t' \ 330 | 'Line18b_TransfersFromNonFed_LevinH5_Tot\t' \ 331 | 'Line18c_TotalNonFedTransfers_Tot\t' \ 332 | 'Line19_TotalReceipts_Tot\tLine20_TotalFedReceipts_Tot\t' \ 333 | 'Line21a1_FedShare_Tot\tLine21a2_NonFedShare_Tot\t' \ 334 | 'Line21b_OtherFedOpExps_Tot\tLine21c_TotOpExps_Tot\t' \ 335 | 'Line22_TransToOtherComms_Tot\t' \ 336 | 'Line23_ContribsToFedCandsOrComms_Tot\t' \ 337 | 'Line24_IndptExps_Tot\tLine25_CoordtdExpByPrtyComms_Tot\t' \ 338 | 'Line26_LoanRepayments_Tot\tLine27_LoansMade_Tot\t' \ 339 | 'Line28a_IndivRefunds_Tot\t' \ 340 | 'Line28b_PolPartyCommRefunds_Tot\t' \ 341 | 'Line28c_OtherPolCommRefunds_Tot\t' \ 342 | 'Line28d_TotalContRefunds_Tot\tLine29_OtherDisb_Tot\t' \ 343 | 'Line30a1_SharedFedActH6FedShare_Tot\t' \ 344 | 'Line30a2_SharedFedActH6NonFed_Tot\t' \ 345 | 'Line30b_NonAlloc100PctFedElecActivity_Tot\t' \ 346 | 'Line30c_TotFedElecActivity_Tot\tLine31_TotDisbmts_Tot\t' \ 347 | 'Line32_TotFedDisbmts_Tot\tLine33_TotContribs_Tot\t' \ 348 | 'Line34_TotContribRefunds_Tot\tLine35_NetContribs_Tot\t' \ 349 | 'Line36_TotFedOpExps_Tot\tLine37_OffsetsToOpExps_Tot\t' \ 350 | 'Line38_NetOpExps_Tot\n' 351 | 352 | form_f3_file.write(formf3headerstring) 353 | form_f3p_file.write(formf3pheaderstring) 354 | form_f3x_file.write(formf3xheaderstring) 355 | 356 | # Iterate through all files in the source directory 357 | # and process those with .fec extension 358 | try: 359 | for datafile in glob.glob(os.path.join(sourcedir, '*.fec')): 360 | filename = datafile.replace(sourcedir, '') 361 | print 'Processing: ' + filename 362 | 363 | # Store file ID in variable 364 | imageid = filename.replace('.fec','') 365 | 366 | # Grab first two lines 367 | hdr1 = linecache.getline(datafile, 1) 368 | hdr1list = hdr1.split(delimiter) 369 | hdr2 = linecache.getline(datafile, 2) 370 | hdr2list = hdr2.split(delimiter) 371 | 372 | # Check header version 373 | # Presently, only 6.4, 7.0 and 8.0 are supported 374 | if hdr1list[0].strip('"') == 'HDR': 375 | headerversion = hdr1list[2].strip('"').strip() 376 | else: 377 | shutil.move(datafile, reviewdir + filename.replace('.fec','_INV_HDR.fec')) 378 | continue 379 | 380 | if headerversion != '6.4' and headerversion !='7.0' and headerversion !='8.0': 381 | shutil.move(datafile, reviewdir + filename.replace('.fec','_HDR_' + headerversion + '.fec')) 382 | continue 383 | 384 | # Header 1 is valid, so now let's parse line 2. 385 | # First, retrieve form type 386 | formtype = hdr2list[0].strip('"') 387 | 388 | # Make sure form type is valid 389 | # Supported: 390 | # F3: F3A, F3N 391 | # F3P: F3PA, F3PN 392 | # F3X: F3XA, F3XN 393 | if formtype != 'F3A' and formtype != 'F3N' \ 394 | and formtype != 'F3PA' and formtype != 'F3PN'\ 395 | and formtype != 'F3XA' and formtype != 'F3XN': 396 | shutil.move(datafile, reviewdir + filename.replace('.fec','_INV_FORMTYPE_' + formtype + '.fec')) 397 | continue 398 | 399 | # At this point, the header is valid. 400 | # Run custom code to ensure various header types conform. 401 | 402 | # Header 6.4, Forms F3PA and F3PN 403 | if headerversion == '6.4' and formtype.startswith('F3P'): 404 | 405 | # 6.4 does not have separate values for line 17a, so we 406 | # need to insert blank values for 17a1 and 17a2 and leave 407 | # the reported values (period and total) for 17a3. 408 | cols = hdr2.split(delimiter) 409 | cols.insert(34, '') 410 | cols.insert(34, '') 411 | cols.insert(121, '') 412 | cols.insert(121, '') 413 | 414 | # Convert list back to string 415 | hdr2 = delimiter.join(map(str, cols)) 416 | 417 | # Generic cleanup of header lines 418 | 419 | # Change all tabs and newlines to spaces 420 | lineclean = hdr2.expandtabs(1).replace('\r',' ').replace('\n',' ') 421 | # Remove leading and trailing whitespace 422 | lineclean = lineclean.strip() 423 | # Remove all instances of two spaces 424 | while ' ' in lineclean: 425 | lineclean = lineclean.replace(' ',' ') 426 | # Remove spaces immediately before or after a delimiter 427 | while ' ' + delimiter in lineclean: 428 | lineclean = lineclean.replace(' ' + delimiter, delimiter) 429 | while delimiter + ' ' in lineclean: 430 | lineclean = lineclean.replace(delimiter + ' ', delimiter) 431 | # Remove leading and trailing quotation marks 432 | while lineclean.startswith('"') or lineclean.endswith('"') or lineclean.startswith("'") or lineclean.endswith("'"): 433 | lineclean = lineclean.strip().strip('"').strip("'").strip() 434 | # Remove double quotation marks when immediately before or after a delimiter. 435 | while '"' + delimiter in lineclean: 436 | lineclean = lineclean.replace('"' + delimiter, delimiter) 437 | while delimiter + '"' in lineclean: 438 | lineclean = lineclean.replace(delimiter + '"', delimiter) 439 | # Remove single quotation marks when immediately before or after a delimiter. 440 | while "'" + delimiter in lineclean: 441 | lineclean = lineclean.replace("'" + delimiter, delimiter) 442 | while delimiter + "'" in lineclean: 443 | lineclean = lineclean.replace(delimiter + "'", delimiter) 444 | # Replace '' between two delimiters with just two delimiters 445 | lineclean = lineclean.replace(delimiter + "''" + delimiter, delimiter + delimiter) 446 | # Replace all cases of '' with " 447 | while "''" in lineclean: 448 | lineclean = lineclean.replace("''", '"') 449 | # Replace all cases of "" with " 450 | while '""' in lineclean: 451 | lineclean = lineclean.replace('""', '"') 452 | # Change all instances of ' to '' 453 | lineclean = lineclean.replace("'", "''") 454 | # Insert NULL between delimiters 455 | while delimiter + delimiter in lineclean: 456 | lineclean = lineclean.replace(delimiter + delimiter, delimiter + 'NULL' + delimiter) 457 | # Add image id 458 | lineclean = "'" + imageid + delimiter + lineclean 459 | # Replace delimiters with single quotations and commas 460 | if usedatabaseflag == 1: 461 | lineclean = lineclean.replace(delimiter, "','") 462 | if lineclean.endswith(",'"): 463 | lineclean = lineclean[:-2] 464 | else: 465 | lineclean = lineclean.replace(delimiter, "'\t'") 466 | if lineclean.endswith("\t'"): 467 | lineclean = lineclean[:-2] 468 | # Remove ' from around NULL 469 | lineclean = lineclean.replace(",'NULL'",',NULL').replace("\t'NULL'",'\tNULL') 470 | # Make sure last field has closing ' 471 | if not lineclean.endswith("'") and not lineclean.endswith('NULL'): 472 | lineclean += "'" 473 | 474 | # If database integration has been enabled, send header info 475 | # to the database manager. Note that you will need to modify 476 | # this code if you are not using SQL Server, which processes 477 | # this data with stored procedure calls. 478 | 479 | # When the script is NOT integrated with a database, the file ID 480 | # (imageid) is prefixed to each child row. 481 | if usedatabaseflag == 1: 482 | 483 | # Create stored procedure call 484 | sql = 'EXEC ' 485 | 486 | # Add appropriate stored procedure 487 | if formtype == 'F3A' or formtype == 'F3N': 488 | sql += "dbo.usp_AddF3Header" 489 | elif formtype == 'F3PA' or formtype == 'F3PN': 490 | sql += "dbo.usp_AddF3PHeader" 491 | elif formtype == 'F3XA' or formtype == 'F3XN': 492 | sql += "dbo.usp_AddF3XHeader" 493 | 494 | # Build final sql string, with new line 495 | sql += ' ' + lineclean + '\n' 496 | 497 | # Create SQL Server connection 498 | conn = pyodbc.connect(connstr) 499 | cursor = conn.cursor() 500 | 501 | # Excecute stored procedure 502 | cursor.execute(sql) 503 | sqlresult = cursor.fetchone() 504 | fileid = sqlresult[0] 505 | conn.commit() 506 | conn.close() 507 | 508 | # Alert user if file may have been previously imported 509 | # and move to review directory 510 | if fileid == -1: 511 | print 'This file may already be in the FEC database, so the ' \ 512 | 'header was not imported. See the Review directory.\n' 513 | raw_input('Press Enter to continue...') 514 | shutil.move(datafile, reviewdir + filename) 515 | print '\n' 516 | continue 517 | 518 | # Otherwise, database integration disabled; 519 | # Store ImageID as FileID 520 | # and copy second header line to header text file. 521 | else: 522 | 523 | # Write header to appropriate file 524 | if lineclean.startswith("'"): 525 | lineclean = lineclean[1:] 526 | if lineclean.endswith("'"): 527 | lineclean = lineclean[:-1] 528 | lineclean += '\n' 529 | lineclean = lineclean.replace("'\t","\t").replace("\t'","\t") 530 | colct = len(lineclean.split('\t')) 531 | if formtype == 'F3A' or formtype == 'F3N': 532 | while colct < 94: 533 | lineclean = lineclean.replace('\n', '\t\n') 534 | colct = len(lineclean.split('\t')) 535 | while colct > 94 and lineclean.endswith('\t\n'): 536 | lineclean = lineclean[:-2] + '\n' 537 | colct = len(lineclean.split('\t')) 538 | if colct == 94: 539 | form_f3_file.write(lineclean) 540 | else: 541 | print 'The header row for ' + filename + ' does not have ' \ 542 | 'the correct number of columns. This file will be ' \ 543 | 'moved to the review directory and will not ' \ 544 | 'be imported.\n' 545 | raw_input('Press Enter to continue...') 546 | shutil.move(datafile, reviewdir + filename) 547 | print '\n' 548 | continue 549 | elif formtype == 'F3PA' or formtype == 'F3PN': 550 | while colct < 207: 551 | lineclean = lineclean.replace('\n', '\t\n') 552 | colct = len(lineclean.split('\t')) 553 | while colct > 207 and lineclean.endswith('\t\n'): 554 | lineclean = lineclean[:-2] + '\n' 555 | colct = len(lineclean.split('\t')) 556 | if colct == 207: 557 | form_f3p_file.write(lineclean) 558 | else: 559 | print 'The header row for ' + filename + ' does not have ' \ 560 | 'the correct number of columns. This file will be ' \ 561 | 'moved to the review directory and will not ' \ 562 | 'be imported.\n' 563 | raw_input('Press Enter to continue...') 564 | shutil.move(datafile, reviewdir + filename) 565 | print '\n' 566 | continue 567 | elif formtype == 'F3XA' or formtype == 'F3XN': 568 | while colct < 124: 569 | lineclean = lineclean.replace('\n', '\t\n') 570 | colct = len(lineclean.split('\t')) 571 | while colct > 124 and lineclean.endswith('\t\n'): 572 | lineclean = lineclean[:-2] + '\n' 573 | colct = len(lineclean.split('\t')) 574 | if colct == 124: 575 | form_f3x_file.write(lineclean) 576 | else: 577 | print 'The header row for ' + filename + ' does not have ' \ 578 | 'the correct number of columns. This file will be ' \ 579 | 'moved to the review directory and will not ' \ 580 | 'be imported.\n' 581 | raw_input('Press Enter to continue...') 582 | shutil.move(datafile, reviewdir + filename) 583 | print '\n' 584 | continue 585 | else: 586 | print 'An unexpected error occurred while processing the ' \ 587 | 'header for ' + filename + '. This file has been ' \ 588 | 'moved to the review directory and will not ' \ 589 | 'be imported.\n' 590 | raw_input('Press Enter to continue...') 591 | shutil.move(datafile, reviewdir + filename) 592 | print '\n' 593 | continue 594 | 595 | # At this point, we have a valid header for a new file 596 | # Copy each subsequent line to the appropriate output file. 597 | for line in open(datafile, 'rb'): 598 | 599 | # If the row is just white space, skip it 600 | if line.replace('/n','').expandtabs(1).replace(' ','').replace('"','').replace("'",'').replace(delimiter,'').strip() == '': 601 | continue 602 | 603 | # Skip this row if it's a header line 604 | linetest = line.replace(delimiter,'').replace('"','').replace("'",'').upper() 605 | if linetest.startswith('HDR') or linetest.startswith('F3'): 606 | continue 607 | 608 | # THIS SECTION INCLUDES CUSTOM CODE TO MAKE SURE DIFFERENT HEADER VERSIONS CONFORM 609 | 610 | # Header 8.0: 611 | # ----------- 612 | if headerversion == '8.0': 613 | # Schedule A: 614 | # ----------- 615 | # Contribution Purpose Code (field 23) removed 616 | # Add placeholder 617 | if linetest.startswith('SA'): 618 | cols = line.split(delimiter) 619 | cols.insert(22, '') 620 | line = delimiter.join(map(str, cols)) 621 | 622 | # Schedule B: 623 | # ----------- 624 | # Expenditure Purpose Code (field 23) removed 625 | # Add placeholder 626 | elif linetest.startswith('SB'): 627 | cols = line.split(delimiter) 628 | cols.insert(22, '') 629 | line = delimiter.join(map(str, cols)) 630 | 631 | # Schedule E: 632 | # ----------- 633 | # Expenditure Purpose Code (field 23) removed 634 | # Add placeholder 635 | elif linetest.startswith('SE'): 636 | cols = line.split(delimiter) 637 | cols.insert(22, '') 638 | line = delimiter.join(map(str, cols)) 639 | 640 | # Parse the line on the delimiter and put in a list 641 | cols = line.split(delimiter) 642 | 643 | # Add header type and ID 644 | # Old code: datarow = formtype + delimiter + str(fileid) + delimiter + line 645 | datarow = formtype + delimiter + str(imageid) + delimiter + line 646 | 647 | # Clean up the line 648 | # Change all tabs and newlines to spaces, 649 | # and strip leading/trailing whitespace 650 | datarow = datarow.replace('\t',' ').replace('\r',' ').replace('\n',' ').strip() 651 | 652 | # Remove leading and trailing whitespace 653 | # datarow = datarow.strip() 654 | # Remove all instances of two spaces 655 | while ' ' in datarow: 656 | datarow = datarow.replace(' ',' ') 657 | # Remove spaces immediately before or after a delimiter 658 | while ' ' + delimiter in datarow: 659 | datarow = datarow.replace(' ' + delimiter, delimiter) 660 | while delimiter + ' ' in datarow: 661 | datarow = datarow.replace(delimiter + ' ', delimiter) 662 | # Remove leading and trailing quotation marks 663 | while datarow.startswith('"') or datarow.endswith('"') or datarow.startswith("'") or datarow.endswith("'"): 664 | datarow = datarow.strip().strip('"').strip("'").strip() 665 | # Remove double quotation marks when immediately before or after a delimiter. 666 | while '"' + delimiter in datarow: 667 | datarow = datarow.replace('"' + delimiter, delimiter) 668 | while delimiter + '"' in datarow: 669 | datarow = datarow.replace(delimiter + '"', delimiter) 670 | # Remove single quotation marks when immediately before or after a delimiter. 671 | while "'" + delimiter in datarow: 672 | datarow = datarow.replace("'" + delimiter, delimiter) 673 | while delimiter + "'" in datarow: 674 | datarow = datarow.replace(delimiter + "'", delimiter) 675 | # Replace '' between two delimiters with just two delimiters 676 | datarow = datarow.replace(delimiter + "''" + delimiter, delimiter + delimiter) 677 | # Replace all cases of '' with " 678 | while "''" in datarow: 679 | datarow = datarow.replace("''", '"') 680 | # Replace all cases of "" with " 681 | while '""' in datarow: 682 | datarow = datarow.replace('""', '"') 683 | # Replace all delimiters with tabs and add newline 684 | datarow = datarow.replace(delimiter, '\t') + '\n' 685 | 686 | # Now write the data row to the appropriate file 687 | rowtype = cols[0].strip('"') 688 | colct = len(datarow.split('\t')) 689 | 690 | if rowtype.startswith('SA'): 691 | while colct < 47: 692 | datarow = datarow.replace('\n', '\t\n') 693 | colct = len(datarow.split('\t')) 694 | while colct > 47 and datarow.endswith('\t\n'): 695 | datarow = datarow[:-2] + '\n' 696 | colct = len(datarow.split('\t')) 697 | if colct == 47: 698 | sched_a_file.write(datarow) 699 | else: 700 | review_file.write(datarow) 701 | elif rowtype.startswith('SB'): 702 | while colct < 46: 703 | datarow = datarow.replace('\n', '\t\n') 704 | colct = len(datarow.split('\t')) 705 | while colct > 46 and datarow.endswith('\t\n'): 706 | datarow = datarow[:-2] + '\n' 707 | colct = len(datarow.split('\t')) 708 | if colct == 46: 709 | sched_b_file.write(datarow) 710 | else: 711 | review_file.write(datarow) 712 | elif rowtype.startswith('SC/'): 713 | while colct < 40: 714 | datarow = datarow.replace('\n', '\t\n') 715 | colct = len(datarow.split('\t')) 716 | while colct > 40 and datarow.endswith('\t\n'): 717 | datarow = datarow[:-2] + '\n' 718 | colct = len(datarow.split('\t')) 719 | if colct == 40: 720 | sched_c_file.write(datarow) 721 | else: 722 | review_file.write(datarow) 723 | elif rowtype.startswith('SC1/'): 724 | while colct < 50: 725 | datarow = datarow.replace('\n', '\t\n') 726 | colct = len(datarow.split('\t')) 727 | while colct > 50 and datarow.endswith('\t\n'): 728 | datarow = datarow[:-2] + '\n' 729 | colct = len(datarow.split('\t')) 730 | if colct == 50: 731 | sched_c1_file.write(datarow) 732 | else: 733 | review_file.write(datarow) 734 | elif rowtype.startswith('SC2/'): 735 | while colct < 19: 736 | datarow = datarow.replace('\n', '\t\n') 737 | colct = len(datarow.split('\t')) 738 | while colct > 19 and datarow.endswith('\t\n'): 739 | datarow = datarow[:-2] + '\n' 740 | colct = len(datarow.split('\t')) 741 | if colct == 19: 742 | sched_c2_file.write(datarow) 743 | else: 744 | review_file.write(datarow) 745 | elif rowtype.startswith('SD'): 746 | while colct < 22: 747 | datarow = datarow.replace('\n', '\t\n') 748 | colct = len(datarow.split('\t')) 749 | while colct > 22 and datarow.endswith('\t\n'): 750 | datarow = datarow[:-2] + '\n' 751 | colct = len(datarow.split('\t')) 752 | if colct == 22: 753 | sched_d_file.write(datarow) 754 | else: 755 | review_file.write(datarow) 756 | elif rowtype.startswith('SE'): 757 | while colct < 46: 758 | datarow = datarow.replace('\n', '\t\n') 759 | colct = len(datarow.split('\t')) 760 | while colct > 46 and datarow.endswith('\t\n'): 761 | datarow = datarow[:-2] + '\n' 762 | colct = len(datarow.split('\t')) 763 | if colct == 46: 764 | sched_e_file.write(datarow) 765 | else: 766 | review_file.write(datarow) 767 | elif rowtype.startswith('TEXT'): 768 | while colct < 8: 769 | datarow = datarow.replace('\n', '\t\n') 770 | colct = len(datarow.split('\t')) 771 | while colct > 8 and datarow.endswith('\t\n'): 772 | datarow = datarow[:-2] + '\n' 773 | colct = len(datarow.split('\t')) 774 | if colct == 8: 775 | text_file.write(datarow) 776 | else: 777 | review_file.write(datarow) 778 | else: 779 | review_file.write(datarow) 780 | 781 | # Move the file to the processed directory 782 | shutil.move(datafile, destdir + filename) 783 | 784 | except: 785 | raw_input('An unexpected error has occurred regarding file ' + imageid + '. Press Enter to continue.') 786 | shutil.move(datafile, reviewdir + filename) 787 | 788 | finally: 789 | sched_a_file.close() 790 | sched_b_file.close() 791 | sched_c_file.close() 792 | sched_c1_file.close() 793 | sched_c2_file.close() 794 | sched_d_file.close() 795 | sched_e_file.close() 796 | text_file.close() 797 | review_file.close() 798 | 799 | if usedatabaseflag == 0: 800 | form_f3_file.close() 801 | form_f3p_file.close() 802 | form_f3x_file.close() 803 | -------------------------------------------------------------------------------- /FECScraper.sql: -------------------------------------------------------------------------------- 1 | /* 2 | FEC database creation scripts: 3 | ------------------------------ 4 | By Christopher Schnaars, USA Today 5 | 6 | In this file, you'll find all the necessary scripts to create an FEC database on SQL Server, 7 | including tables and stored procedures used by the FEC Scraper and FEC Parser Python scripts 8 | to interact with the database. 9 | 10 | These scripts were developed on SQL Server 2008 R2 but should work on older versions, including 11 | SQL Server 2000 and 2005. You can use the schema to create similar objects for other 12 | database managers. 13 | 14 | Once you create a database (Step 1), you should be able to run the rest of this file as a batch to 15 | create all the tables, stored procedures and triggers at once. 16 | 17 | Please note: 18 | None of the tables in this batch is indexed. If you decide to use these tables as the final 19 | resting place for your data rather than as repositories, you probably should create indexes 20 | and keys. 21 | 22 | The tables house all fields contained in the FEC data and add two fields: 23 | * ImageID is the six digit ID number assigned by the FEC for a particular data file. So, for 24 | example, if you download 421841.fec and add the contents of that file to the database, 421841 25 | will be housed in the ImageID field in this table. 26 | * Active is a bit field to indicate whether the file is the current file. The default value is 1. 27 | If a report is amended, this field will be set to 0 for all amended reports. 28 | 29 | Database triggers (scripted below) control the Active field for you. If you use a different database 30 | manager, you'll have to come up with logic to handle this field, set it manually or delete data that 31 | has been amended. 32 | 33 | */ 34 | 35 | 36 | 37 | -- Step 1: Create the database 38 | -- Create a new database on your server. These scripts assume you've called the database FEC. 39 | -- If not, modify Step 2 to point to the database you've created. 40 | 41 | 42 | 43 | -- Step 2: Point this file to your database 44 | -- Modify this code to point to your database 45 | USE FEC; 46 | GO 47 | 48 | 49 | 50 | -- Step 3: Create header tables 51 | SET ANSI_NULLS ON 52 | GO 53 | 54 | SET QUOTED_IDENTIFIER ON 55 | GO 56 | 57 | SET ANSI_PADDING ON 58 | GO 59 | 60 | -- This table houses filings by candidates for the House of Representatives 61 | CREATE TABLE [dbo].[Contribs_FormF3]( 62 | [ImageID] [varchar](9) NOT NULL, 63 | [Active] [bit] NOT NULL, 64 | [FormType] [char](4) NOT NULL, 65 | [CommID] [char](9) NOT NULL, 66 | [CommName] [varchar](200) NULL, 67 | [AddressChange] [varchar](1) NULL, 68 | [CommAddress1] [varchar](34) NULL, 69 | [CommAddress2] [varchar](34) NULL, 70 | [CommCity] [varchar](30) NULL, 71 | [CommState] [varchar](2) NULL, 72 | [CommZip] [varchar](9) NULL, 73 | [ElecState] [varchar](2) NULL, 74 | [ElecDist] [varchar](2) NULL, 75 | [ReptCode] [varchar](3) NULL, 76 | [ElecCode] [varchar](5) NULL, 77 | [strElecDate] [varchar](8) NULL, 78 | [StateOfElec] [varchar](2) NULL, 79 | [strCovgFromDate] [varchar](8) NULL, 80 | [strCovgToDate] [varchar](8) NULL, 81 | [TreasLastName] [varchar](30) NOT NULL, 82 | [TreasFirstName] [varchar](20) NOT NULL, 83 | [TreasMidName] [varchar](20) NULL, 84 | [TreasPrefix] [varchar](10) NULL, 85 | [TreasSuffix] [varchar](10) NULL, 86 | [strDateSigned] [varchar](8) NULL, 87 | [Line6a_TotalContribs_Prd] [varchar](12) NULL, 88 | [Line6b_TotalContribRefunds_Prd] [varchar](12) NULL, 89 | [Line6c_NetContribs_Prd] [varchar](12) NULL, 90 | [Line7a_TotOpExps_Prd] [varchar](12) NULL, 91 | [Line7b_TotOffsetToOpExps_Prd] [varchar](12) NULL, 92 | [Line7c_NetOpExps_Prd] [varchar](12) NULL, 93 | [Line8_CashOnHandAtClose_Prd] [varchar](12) NULL, 94 | [Line9_DebtsTo_Prd] [varchar](12) NULL, 95 | [Line10_DebtsBy_Prd] [varchar](12) NULL, 96 | [Line11a1_IndivsItemized_Prd] [varchar](12) NULL, 97 | [Line11a2_IndivsUnitemized_Prd] [varchar](12) NULL, 98 | [Line11a3_IndivsContribTotal_Prd] [varchar](12) NULL, 99 | [Line11b_PolPtyComms_Prd] [varchar](12) NULL, 100 | [Line11c_OtherPACs_Prd] [varchar](12) NULL, 101 | [Line11d_Candidate_Prd] [varchar](12) NULL, 102 | [Line11e_TotalContribs_Prd] [varchar](12) NULL, 103 | [Line12_TransfersFrom_Prd] [varchar](12) NULL, 104 | [Line13a_LoansByCand_Prd] [varchar](12) NULL, 105 | [Line13b_OtherLoans_Prd] [varchar](12) NULL, 106 | [Line13c_TotLoans_Prd] [varchar](12) NULL, 107 | [Line14_OffsetsToOpExps_Prd] [varchar](12) NULL, 108 | [Line15_OtherReceipts_Prd] [varchar](12) NULL, 109 | [Line16_TotReceipts_Prd] [varchar](12) NULL, 110 | [Line17_OpExps_Prd] [varchar](12) NULL, 111 | [Line18_TransToOtherComms_Prd] [varchar](12) NULL, 112 | [Line19a_LoanRepaymts_Cand_Prd] [varchar](12) NULL, 113 | [Line19b_LoanRepaymts_Other_Prd] [varchar](12) NULL, 114 | [Line19c_TotLoanRepaymts_Prd] [varchar](12) NULL, 115 | [Loan20a_IndivRefunds_Prd] [varchar](12) NULL, 116 | [Line20b_PolPartyCommRefunds_Prd] [varchar](12) NULL, 117 | [Line20c_OtherPolCommRefunds_Prd] [varchar](12) NULL, 118 | [Line20d_TotContRefunds_Prd] [varchar](12) NULL, 119 | [Line21_OtherDisb_Prd] [varchar](12) NULL, 120 | [Line22_TotDisb_Prd] [varchar](12) NULL, 121 | [Line23_CashBegin_Prd] [varchar](12) NULL, 122 | [Line24_TotReceipts_Prd] [varchar](12) NULL, 123 | [Line25_Subtotal] [varchar](12) NULL, 124 | [Line26_TotDisbThisPrd_Prd] [varchar](12) NULL, 125 | [Line27_CashAtClose_Prd] [varchar](12) NULL, 126 | [Line6a_TotalContribs_Tot] [varchar](12) NULL, 127 | [Line6b_TotalContribRefunds_Tot] [varchar](12) NULL, 128 | [Line6c_NetContribs_Tot] [varchar](12) NULL, 129 | [Line7a_TotOpExps_Tot] [varchar](12) NULL, 130 | [Line7b_TotOffsetToOpExps_Tot] [varchar](12) NULL, 131 | [Line7c_NetOpExps_Tot] [varchar](12) NULL, 132 | [Line11a1_IndivsItemized_Tot] [varchar](12) NULL, 133 | [Line11a2_IndivsUnitemized_Tot] [varchar](12) NULL, 134 | [Line11a3_IndivsContribTotal_Tot] [varchar](12) NULL, 135 | [Line11b_PolPtyComms_Tot] [varchar](12) NULL, 136 | [Line11c_OtherPACs_Tot] [varchar](12) NULL, 137 | [Line11d_Candidate_Tot] [varchar](12) NULL, 138 | [Line11e_TotalContribs_Tot] [varchar](12) NULL, 139 | [Line12_TransfersFrom_Tot] [varchar](12) NULL, 140 | [Line13a_LoansByCand_Tot] [varchar](12) NULL, 141 | [Line13b_OtherLoans_Tot] [varchar](12) NULL, 142 | [Line13c_TotLoans_Tot] [varchar](12) NULL, 143 | [Line14_OffsetsToOpExps_Tot] [varchar](12) NULL, 144 | [Line15_OtherReceipts_Tot] [varchar](12) NULL, 145 | [Line16_TotReceipts_Tot] [varchar](12) NULL, 146 | [Line17_OpExps_Tot] [varchar](12) NULL, 147 | [Line18_TransToOtherComms_Tot] [varchar](12) NULL, 148 | [Line19a_LoanRepaymts_Cand_Tot] [varchar](12) NULL, 149 | [Line19b_LoanRepaymts_Other_Tot] [varchar](12) NULL, 150 | [Line19c_TotLoanRepaymts_Tot] [varchar](12) NULL, 151 | [Loan20a_IndivRefunds_Tot] [varchar](12) NULL, 152 | [Line20b_PolPartyCommRefunds_Tot] [varchar](12) NULL, 153 | [Line20c_OtherPolCommRefunds_Tot] [varchar](12) NULL, 154 | [Line20d_TotContRefunds_Tot] [varchar](12) NULL, 155 | [Line21_OtherDisb_Tot] [varchar](12) NULL, 156 | [Line22_TotDisb_Tot] [varchar](12) NULL, 157 | CONSTRAINT [PK_Contribs_FormF3] PRIMARY KEY CLUSTERED 158 | ( 159 | [ImageID] ASC 160 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 161 | ) ON [PRIMARY] 162 | GO 163 | 164 | SET ANSI_PADDING OFF 165 | GO 166 | 167 | ALTER TABLE [dbo].[Contribs_FormF3] ADD CONSTRAINT [DF_Contribs_FormF3_Active] DEFAULT ((1)) FOR [Active] 168 | GO 169 | 170 | SET ANSI_PADDING ON 171 | GO 172 | 173 | -- This table houses filings by presidential candidates 174 | CREATE TABLE [dbo].[Contribs_FormF3P]( 175 | [ImageID] [varchar](9) NOT NULL, 176 | [Active] [bit] NOT NULL, 177 | [FormType] [char](4) NOT NULL, 178 | [CommID] [char](9) NOT NULL, 179 | [CommName] [varchar](200) NULL, 180 | [AddressChange] [varchar](1) NULL, 181 | [CommAddress1] [varchar](34) NULL, 182 | [CommAddress2] [varchar](34) NULL, 183 | [CommCity] [varchar](30) NULL, 184 | [CommState] [varchar](2) NULL, 185 | [CommZip] [varchar](9) NULL, 186 | [ActivityPrim] [varchar](1) NULL, 187 | [ActivityGen] [varchar](1) NULL, 188 | [ReptCode] [varchar](3) NULL, 189 | [ElecCode] [varchar](5) NULL, 190 | [strElecDate] [varchar](8) NULL, 191 | [ElecState] [varchar](2) NULL, 192 | [strFromDate] [varchar](8) NULL, 193 | [strToDate] [varchar](8) NULL, 194 | [TreasLastName] [varchar](30) NOT NULL, 195 | [TreasFirstName] [varchar](20) NOT NULL, 196 | [TreasMidName] [varchar](20) NULL, 197 | [TreasPrefix] [varchar](10) NULL, 198 | [TreasSuffix] [varchar](10) NULL, 199 | [strDateSigned] [char](8) NOT NULL, 200 | [Line6_CashBegin] [varchar](12) NULL, 201 | [Line7_TotReceipts] [varchar](12) NULL, 202 | [Line8_Subtotal] [varchar](12) NULL, 203 | [Line9_TotalDisb] [varchar](12) NULL, 204 | [Line10_CashClose] [varchar](12) NULL, 205 | [Line11_DebtsTo] [varchar](12) NULL, 206 | [Line12_DebtsBy] [varchar](12) NULL, 207 | [Line13_ExpendsSubToLimits] [varchar](12) NULL, 208 | [Line14_NetContribs] [varchar](12) NULL, 209 | [Line15_NetOpExps] [varchar](12) NULL, 210 | [Line16_FedFunds_Prd] [varchar](12) NULL, 211 | [Line17a1_IndivsItemzd_Prd] [varchar](12) NULL, 212 | [Line17a2_IndivsUnItemzd_Prd] [varchar](12) NULL, 213 | [Line17a3_IndContTot_Prd] [varchar](12) NULL, 214 | [Line17b_PolPartyComms_Prd] [varchar](12) NULL, 215 | [Line17c_OtherPACs_Prd] [varchar](12) NULL, 216 | [Line17d_Candidate_Prd] [varchar](12) NULL, 217 | [Line17e_TotContribs_Prd] [varchar](12) NULL, 218 | [Line18_TransfersFrom_Prd] [varchar](12) NULL, 219 | [Line19a_CandLoans_Prd] [varchar](12) NULL, 220 | [Line19b_OtherLoans_Prd] [varchar](12) NULL, 221 | [Line19c_TotLoans_Prd] [varchar](12) NULL, 222 | [Line20a_Operating_Prd] [varchar](12) NULL, 223 | [Line20b_Fundraising_Prd] [varchar](12) NULL, 224 | [Line20c_LegalAcctg_Prd] [varchar](12) NULL, 225 | [Line20d_TotExpOffsets_Prd] [varchar](12) NULL, 226 | [Line21_OtherReceipts_Prd] [varchar](12) NULL, 227 | [Line22_TotReceipts_Prd] [varchar](12) NULL, 228 | [Line23_OpExpends_Prd] [varchar](12) NULL, 229 | [Line24_TransToOtherComms_Prd] [varchar](12) NULL, 230 | [Line25_FundraisingDisbursed_Prd] [varchar](12) NULL, 231 | [Line26_ExemptLegalAcctgDisb_Prd] [varchar](12) NULL, 232 | [Line27a_CandRepymts_Prd] [varchar](12) NULL, 233 | [Line27b_OtherRepymts_Prd] [varchar](12) NULL, 234 | [Line27c_TotLoanRepymts_Prd] [varchar](12) NULL, 235 | [Line28a_IndivRefunds_Prd] [varchar](12) NULL, 236 | [Line28b_PolPartyCommRefunds_Prd] [varchar](12) NULL, 237 | [Line28c_OtherPolCommRefunds_Prd] [varchar](12) NULL, 238 | [Line28d_TotalContRefunds_Prd] [varchar](12) NULL, 239 | [Line29_OtherDisb_Prd] [varchar](12) NULL, 240 | [Line30_TotDisb_Prd] [varchar](12) NULL, 241 | [Line31_ItemsToLiq_Prd] [varchar](12) NULL, 242 | [AllocAlabama_Prd] [varchar](12) NULL, 243 | [AllocAlaska_Prd] [varchar](12) NULL, 244 | [AllocArizona_Prd] [varchar](12) NULL, 245 | [AllocArkansas_Prd] [varchar](12) NULL, 246 | [AllocCalifornia_Prd] [varchar](12) NULL, 247 | [AllocColorado_Prd] [varchar](12) NULL, 248 | [AllocConnecticut_Prd] [varchar](12) NULL, 249 | [AllocDelaware_Prd] [varchar](12) NULL, 250 | [AllocDistCol_Prd] [varchar](12) NULL, 251 | [AllocFlorida_Prd] [varchar](12) NULL, 252 | [AllocGeorgia_Prd] [varchar](12) NULL, 253 | [AllocHawaii_Prd] [varchar](12) NULL, 254 | [AllocIdaho_Prd] [varchar](12) NULL, 255 | [AllocIllinois_Prd] [varchar](12) NULL, 256 | [AllocIndiana_Prd] [varchar](12) NULL, 257 | [AllocIowa_Prd] [varchar](12) NULL, 258 | [AllocKansas_Prd] [varchar](12) NULL, 259 | [AllocKentucky_Prd] [varchar](12) NULL, 260 | [AllocLouisiana_Prd] [varchar](12) NULL, 261 | [AllocMaine_Prd] [varchar](12) NULL, 262 | [AllocMaryland_Prd] [varchar](12) NULL, 263 | [AllocMassachusetts_Prd] [varchar](12) NULL, 264 | [AllocMichigan_Prd] [varchar](12) NULL, 265 | [AllocMinnesota_Prd] [varchar](12) NULL, 266 | [AllocMississippi_Prd] [varchar](12) NULL, 267 | [AllocMissouri_Prd] [varchar](12) NULL, 268 | [AllocMontana_Prd] [varchar](12) NULL, 269 | [AllocNebraska_Prd] [varchar](12) NULL, 270 | [AllocNevada_Prd] [varchar](12) NULL, 271 | [AllocNewHampshire_Prd] [varchar](12) NULL, 272 | [AllocNewJersey_Prd] [varchar](12) NULL, 273 | [AllocNewMexico_Prd] [varchar](12) NULL, 274 | [AllocNewYork_Prd] [varchar](12) NULL, 275 | [AllocNorthCarolina_Prd] [varchar](12) NULL, 276 | [AllocNorthDakota_Prd] [varchar](12) NULL, 277 | [AllocOhio_Prd] [varchar](12) NULL, 278 | [AllocOklahoma_Prd] [varchar](12) NULL, 279 | [AllocOregon_Prd] [varchar](12) NULL, 280 | [AllocPennsylvania_Prd] [varchar](12) NULL, 281 | [AllocRhodeIsland_Prd] [varchar](12) NULL, 282 | [AllocSouthCarolina_Prd] [varchar](12) NULL, 283 | [AllocSouthDakota_Prd] [varchar](12) NULL, 284 | [AllocTennessee_Prd] [varchar](12) NULL, 285 | [AllocTexas_Prd] [varchar](12) NULL, 286 | [AllocUtah_Prd] [varchar](12) NULL, 287 | [AllocVermont_Prd] [varchar](12) NULL, 288 | [AllocVirginia_Prd] [varchar](12) NULL, 289 | [AllocWashington_Prd] [varchar](12) NULL, 290 | [AllocWestVirginia_Prd] [varchar](12) NULL, 291 | [AllocWisconsin_Prd] [varchar](12) NULL, 292 | [AllocWyoming_Prd] [varchar](12) NULL, 293 | [AllocPuertoRico_Prd] [varchar](12) NULL, 294 | [AllocGuam_Prd] [varchar](12) NULL, 295 | [AllocVirginIslands_Prd] [varchar](12) NULL, 296 | [AllocStatesTotal_Prd] [varchar](12) NULL, 297 | [Line16_FedFunds_Tot] [varchar](12) NULL, 298 | [Line17a1_IndivsItemzd_Tot] [varchar](12) NULL, 299 | [Line17a2_IndivsUnItemzd_Tot] [varchar](12) NULL, 300 | [Line17a3_IndContTot_Tot] [varchar](12) NULL, 301 | [Line17b_PolPartyComms_Tot] [varchar](12) NULL, 302 | [Line17c_OtherPACs_Tot] [varchar](12) NULL, 303 | [Line17d_Candidate_Tot] [varchar](12) NULL, 304 | [Line17e_TotContribs_Tot] [varchar](12) NULL, 305 | [Line18_TransfersFrom_Tot] [varchar](12) NULL, 306 | [Line19a_CandLoans_Tot] [varchar](12) NULL, 307 | [Line19b_OtherLoans_Tot] [varchar](12) NULL, 308 | [Line19c_TotLoans_Tot] [varchar](12) NULL, 309 | [Line20a_Operating_Tot] [varchar](12) NULL, 310 | [Line20b_Fundraising_Tot] [varchar](12) NULL, 311 | [Line20c_LegalAcctg_Tot] [varchar](12) NULL, 312 | [Line20d_TotExpOffsets_Tot] [varchar](12) NULL, 313 | [Line21_OtherReceipts_Tot] [varchar](12) NULL, 314 | [Line22_TotReceipts_Tot] [varchar](12) NULL, 315 | [Line23_OpExpends_Tot] [varchar](12) NULL, 316 | [Line24_TransToOtherComms_Tot] [varchar](12) NULL, 317 | [Line25_FundraisingDisbursed_Tot] [varchar](12) NULL, 318 | [Line26_ExemptLegalAcctgDisb_Tot] [varchar](12) NULL, 319 | [Line27a_CandRepymts_Tot] [varchar](12) NULL, 320 | [Line27b_OtherRepymts_Tot] [varchar](12) NULL, 321 | [Line27c_TotLoanRepymts_Tot] [varchar](12) NULL, 322 | [Line28a_IndivRefunds_Tot] [varchar](12) NULL, 323 | [Line28b_PolPartyCommRefunds_Tot] [varchar](12) NULL, 324 | [Line28c_OtherPolCommRefunds_Tot] [varchar](12) NULL, 325 | [Line28d_TotalContRefunds_Tot] [varchar](12) NULL, 326 | [Line29_OtherDisb_Tot] [varchar](12) NULL, 327 | [Line30_TotDisb_Tot] [varchar](12) NULL, 328 | [AllocAlabama_Tot] [varchar](12) NULL, 329 | [AllocAlaska_Tot] [varchar](12) NULL, 330 | [AllocArizona_Tot] [varchar](12) NULL, 331 | [AllocArkansas_Tot] [varchar](12) NULL, 332 | [AllocCalifornia_Tot] [varchar](12) NULL, 333 | [AllocColorado_Tot] [varchar](12) NULL, 334 | [AllocConnecticut_Tot] [varchar](12) NULL, 335 | [AllocDelaware_Tot] [varchar](12) NULL, 336 | [AllocDistCol_Tot] [varchar](12) NULL, 337 | [AllocFlorida_Tot] [varchar](12) NULL, 338 | [AllocGeorgia_Tot] [varchar](12) NULL, 339 | [AllocHawaii_Tot] [varchar](12) NULL, 340 | [AllocIdaho_Tot] [varchar](12) NULL, 341 | [AllocIllinois_Tot] [varchar](12) NULL, 342 | [AllocIndiana_Tot] [varchar](12) NULL, 343 | [AllocIowa_Tot] [varchar](12) NULL, 344 | [AllocKansas_Tot] [varchar](12) NULL, 345 | [AllocKentucky_Tot] [varchar](12) NULL, 346 | [AllocLouisiana_Tot] [varchar](12) NULL, 347 | [AllocMaine_Tot] [varchar](12) NULL, 348 | [AllocMaryland_Tot] [varchar](12) NULL, 349 | [AllocMassachusetts_Tot] [varchar](12) NULL, 350 | [AllocMichigan_Tot] [varchar](12) NULL, 351 | [AllocMinnesota_Tot] [varchar](12) NULL, 352 | [AllocMississippi_Tot] [varchar](12) NULL, 353 | [AllocMissouri_Tot] [varchar](12) NULL, 354 | [AllocMontana_Tot] [varchar](12) NULL, 355 | [AllocNebraska_Tot] [varchar](12) NULL, 356 | [AllocNevada_Tot] [varchar](12) NULL, 357 | [AllocNewHampshire_Tot] [varchar](12) NULL, 358 | [AllocNewJersey_Tot] [varchar](12) NULL, 359 | [AllocNewMexico_Tot] [varchar](12) NULL, 360 | [AllocNewYork_Tot] [varchar](12) NULL, 361 | [AllocNorthCarolina_Tot] [varchar](12) NULL, 362 | [AllocNorthDakota_Tot] [varchar](12) NULL, 363 | [AllocOhio_Tot] [varchar](12) NULL, 364 | [AllocOklahoma_Tot] [varchar](12) NULL, 365 | [AllocOregon_Tot] [varchar](12) NULL, 366 | [AllocPennsylvania_Tot] [varchar](12) NULL, 367 | [AllocRhodeIsland_Tot] [varchar](12) NULL, 368 | [AllocSouthCarolina_Tot] [varchar](12) NULL, 369 | [AllocSouthDakota_Tot] [varchar](12) NULL, 370 | [AllocTennessee_Tot] [varchar](12) NULL, 371 | [AllocTexas_Tot] [varchar](12) NULL, 372 | [AllocUtah_Tot] [varchar](12) NULL, 373 | [AllocVermont_Tot] [varchar](12) NULL, 374 | [AllocVirginia_Tot] [varchar](12) NULL, 375 | [AllocWashington_Tot] [varchar](12) NULL, 376 | [AllocWestVirginia_Tot] [varchar](12) NULL, 377 | [AllocWisconsin_Tot] [varchar](12) NULL, 378 | [AllocWyoming_Tot] [varchar](12) NULL, 379 | [AllocPuertoRico_Tot] [varchar](12) NULL, 380 | [AllocGuam_Tot] [varchar](12) NULL, 381 | [AllocVirginIslands_Tot] [varchar](12) NULL, 382 | [AllocStatesTotal_Tot] [varchar](12) NULL, 383 | CONSTRAINT [PK_Contribs_FormF3P] PRIMARY KEY CLUSTERED 384 | ( 385 | [ImageID] ASC 386 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 387 | ) ON [PRIMARY] 388 | GO 389 | 390 | SET ANSI_PADDING OFF 391 | GO 392 | 393 | ALTER TABLE [dbo].[Contribs_FormF3P] ADD CONSTRAINT [DF_Contribs_FormF3P_Active] DEFAULT ((1)) FOR [Active] 394 | GO 395 | 396 | SET ANSI_PADDING ON 397 | GO 398 | 399 | -- This table houses filings by PACs and other organizations 400 | CREATE TABLE [dbo].[Contribs_FormF3X]( 401 | [ImageID] [varchar](9) NOT NULL, 402 | [Active] [bit] NOT NULL, 403 | [FormType] [char](4) NOT NULL, 404 | [CommID] [char](9) NOT NULL, 405 | [CommName] [varchar](200) NULL, 406 | [AddressChange] [varchar](1) NULL, 407 | [CommAddress1] [varchar](34) NULL, 408 | [CommAddress2] [varchar](34) NULL, 409 | [CommCity] [varchar](30) NULL, 410 | [CommState] [varchar](2) NULL, 411 | [CommZip] [varchar](9) NULL, 412 | [ReptCode] [varchar](3) NULL, 413 | [ElecCode] [varchar](5) NULL, 414 | [strElecDate] [varchar](8) NULL, 415 | [ElecState] [varchar](2) NULL, 416 | [strFromDate] [varchar](8) NULL, 417 | [strToDate] [varchar](8) NULL, 418 | [flgQualifiedComm] [varchar](1) NULL, 419 | [TreasLastName] [varchar](30) NOT NULL, 420 | [TreasFirstName] [varchar](20) NOT NULL, 421 | [TreasMidName] [varchar](20) NULL, 422 | [TreasPrefix] [varchar](10) NULL, 423 | [TreasSuffix] [varchar](10) NULL, 424 | [strDateSigned] [char](8) NOT NULL, 425 | [Line6b_CashBegin_Prd] [varchar](12) NULL, 426 | [Line6c_TotalRects_Prd] [varchar](12) NULL, 427 | [Line6d_CashBeginSubtotal_Prd] [varchar](12) NULL, 428 | [Line7_TotDisbmts_Prd] [varchar](12) NULL, 429 | [Line8_CashOnHandAtClose_Prd] [varchar](12) NULL, 430 | [Line9_DebtsTo_Prd] [varchar](12) NULL, 431 | [Line10_DebtsBy_Prd] [varchar](12) NULL, 432 | [Line11a1_Itemized_Prd] [varchar](12) NULL, 433 | [Line11a2_Unitemized_Prd] [varchar](12) NULL, 434 | [Line11a3_Total_Prd] [varchar](12) NULL, 435 | [Line11b_PolPtyComms_Prd] [varchar](12) NULL, 436 | [Line11c_OtherPACs_Prd] [varchar](12) NULL, 437 | [Line11d_TotalContribs_Prd] [varchar](12) NULL, 438 | [Line12_TransfersFrom_Prd] [varchar](12) NULL, 439 | [Line13_AllLoansRcvd_Prd] [varchar](12) NULL, 440 | [Line14_LoanRepymtsRecv_Prd] [varchar](12) NULL, 441 | [Line15_OffsetsToOpExps_Refunds_Prd] [varchar](12) NULL, 442 | [Line16_RefundsOfFedContribs_Prd] [varchar](12) NULL, 443 | [Line17_OtherFedRects_Divds_Prd] [varchar](12) NULL, 444 | [Line18a_TransfersFromNonFedAcct_H3_Prd] [varchar](12) NULL, 445 | [Line18b_TransfersFromNonFed_LevinH5_Prd] [varchar](12) NULL, 446 | [Line18c_TotalNonFedTransfers_Prd] [varchar](12) NULL, 447 | [Line19_TotalReceipts_Prd] [varchar](12) NULL, 448 | [Line20_TotalFedReceipts_Prd] [varchar](12) NULL, 449 | [Line21a1_FedShare_Prd] [varchar](12) NULL, 450 | [Line21a2_NonFedShare_Prd] [varchar](12) NULL, 451 | [Line21b_OtherFedOpExps_Prd] [varchar](12) NULL, 452 | [Line21c_TotOpExps_Prd] [varchar](12) NULL, 453 | [Line22_TransToOtherComms_Prd] [varchar](12) NULL, 454 | [Line23_ContribsToFedCandsOrComms_Prd] [varchar](12) NULL, 455 | [Line24_IndptExps_Prd] [varchar](12) NULL, 456 | [Line25_CoordtdExpByPrtyComms_Prd] [varchar](12) NULL, 457 | [Line26_LoanRepayments_Prd] [varchar](12) NULL, 458 | [Line27_LoansMade_Prd] [varchar](12) NULL, 459 | [Line28a_IndivRefunds_Prd] [varchar](12) NULL, 460 | [Line28b_PolPartyCommRefunds_Prd] [varchar](12) NULL, 461 | [Line28c_OtherPolCommRefunds_Prd] [varchar](12) NULL, 462 | [Line28d_TotalContRefunds_Prd] [varchar](12) NULL, 463 | [Line29_OtherDisb_Prd] [varchar](12) NULL, 464 | [Line30a1_SharedFedActH6FedShare_Prd] [varchar](12) NULL, 465 | [Line30a2_SharedFedActH6NonFed_Prd] [varchar](12) NULL, 466 | [Line30b_NonAlloc100PctFedElecActivity_Prd] [varchar](12) NULL, 467 | [Line30c_TotFedElecActivity_Prd] [varchar](12) NULL, 468 | [Line31_TotDisbmts_Prd] [varchar](12) NULL, 469 | [Line32_TotFedDisbmts_Prd] [varchar](12) NULL, 470 | [Line33_TotContribs_Prd] [varchar](12) NULL, 471 | [Line34_TotContribRefunds_Prd] [varchar](12) NULL, 472 | [Line35_NetContribs_Prd] [varchar](12) NULL, 473 | [Line36_TotFedOpExps_Prd] [varchar](12) NULL, 474 | [Line37_OffsetsToOpExps_Prd] [varchar](12) NULL, 475 | [Line38_NetOpExps_Prd] [varchar](12) NULL, 476 | [Line6b_CashBegin_Tot] [varchar](12) NULL, 477 | [Line6b_Year] [varchar](12) NULL, 478 | [Line6c_TotalRects_Tot] [varchar](12) NULL, 479 | [Line6d_CashBeginSubtotal_Tot] [varchar](12) NULL, 480 | [Line7_TotDisbmts_Tot] [varchar](12) NULL, 481 | [Line8_CashOnHandAtClose_Tot] [varchar](12) NULL, 482 | [Line11a1_Itemized_Tot] [varchar](12) NULL, 483 | [Line11a2_Unitemized_Tot] [varchar](12) NULL, 484 | [Line11a3_Total_Tot] [varchar](12) NULL, 485 | [Line11b_PolPtyComms_Tot] [varchar](12) NULL, 486 | [Line11c_OtherPACs_Tot] [varchar](12) NULL, 487 | [Line11d_TotalContribs_Tot] [varchar](12) NULL, 488 | [Line12_TransfersFrom_Tot] [varchar](12) NULL, 489 | [Line13_AllLoansRcvd_Tot] [varchar](12) NULL, 490 | [Line14_LoanRepymtsRecv_Tot] [varchar](12) NULL, 491 | [Line15_OffsetsToOpExps_Refunds_Tot] [varchar](12) NULL, 492 | [Line16_RefundsOfFedContribs_Tot] [varchar](12) NULL, 493 | [Line17_OtherFedRects_Divds_Tot] [varchar](12) NULL, 494 | [Line18a_TransfersFromNonFedAcct_H3_Tot] [varchar](12) NULL, 495 | [Line18b_TransfersFromNonFed_LevinH5_Tot] [varchar](12) NULL, 496 | [Line18c_TotalNonFedTransfers_Tot] [varchar](12) NULL, 497 | [Line19_TotalReceipts_Tot] [varchar](12) NULL, 498 | [Line20_TotalFedReceipts_Tot] [varchar](12) NULL, 499 | [Line21a1_FedShare_Tot] [varchar](12) NULL, 500 | [Line21a2_NonFedShare_Tot] [varchar](12) NULL, 501 | [Line21b_OtherFedOpExps_Tot] [varchar](12) NULL, 502 | [Line21c_TotOpExps_Tot] [varchar](12) NULL, 503 | [Line22_TransToOtherComms_Tot] [varchar](12) NULL, 504 | [Line23_ContribsToFedCandsOrComms_Tot] [varchar](12) NULL, 505 | [Line24_IndptExps_Tot] [varchar](12) NULL, 506 | [Line25_CoordtdExpByPrtyComms_Tot] [varchar](12) NULL, 507 | [Line26_LoanRepayments_Tot] [varchar](12) NULL, 508 | [Line27_LoansMade_Tot] [varchar](12) NULL, 509 | [Line28a_IndivRefunds_Tot] [varchar](12) NULL, 510 | [Line28b_PolPartyCommRefunds_Tot] [varchar](12) NULL, 511 | [Line28c_OtherPolCommRefunds_Tot] [varchar](12) NULL, 512 | [Line28d_TotalContRefunds_Tot] [varchar](12) NULL, 513 | [Line29_OtherDisb_Tot] [varchar](12) NULL, 514 | [Line30a1_SharedFedActH6FedShare_Tot] [varchar](12) NULL, 515 | [Line30a2_SharedFedActH6NonFed_Tot] [varchar](12) NULL, 516 | [Line30b_NonAlloc100PctFedElecActivity_Tot] [varchar](12) NULL, 517 | [Line30c_TotFedElecActivity_Tot] [varchar](12) NULL, 518 | [Line31_TotDisbmts_Tot] [varchar](12) NULL, 519 | [Line32_TotFedDisbmts_Tot] [varchar](12) NULL, 520 | [Line33_TotContribs_Tot] [varchar](12) NULL, 521 | [Line34_TotContribRefunds_Tot] [varchar](12) NULL, 522 | [Line35_NetContribs_Tot] [varchar](12) NULL, 523 | [Line36_TotFedOpExps_Tot] [varchar](12) NULL, 524 | [Line37_OffsetsToOpExps_Tot] [varchar](12) NULL, 525 | [Line38_NetOpExps_Tot] [varchar](12) NULL, 526 | CONSTRAINT [PK_Contribs_FormF3X] PRIMARY KEY CLUSTERED 527 | ( 528 | [ImageID] ASC 529 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 530 | ) ON [PRIMARY] 531 | GO 532 | 533 | SET ANSI_PADDING OFF 534 | GO 535 | 536 | ALTER TABLE [dbo].[Contribs_FormF3X] ADD CONSTRAINT [DF_Contribs_FormF3X_Active] DEFAULT ((1)) FOR [Active] 537 | GO 538 | 539 | 540 | 541 | -- Step 4: Create child tables 542 | SET ANSI_NULLS ON 543 | GO 544 | 545 | SET QUOTED_IDENTIFIER ON 546 | GO 547 | 548 | SET ANSI_PADDING ON 549 | GO 550 | 551 | -- Schedule A: 552 | CREATE TABLE [dbo].[Contribs_SchedA]( 553 | [USATID] [int] IDENTITY(1,1) NOT NULL, 554 | [ParentType] [varchar](5) NOT NULL, 555 | [ImageID] [int] NOT NULL, 556 | [FormType] [varchar](8) NOT NULL, 557 | [CommID] [char](9) NOT NULL, 558 | [TransID] [varchar](20) NOT NULL, 559 | [BackRefTransID] [varchar](20) NULL, 560 | [BackRefSchedName] [varchar](8) NULL, 561 | [EntityType] [char](3) NOT NULL, 562 | [ContOrgName] [varchar](200) NULL, 563 | [ContLastName] [varchar](30) NULL, 564 | [ContFirstName] [varchar](20) NULL, 565 | [ContMidName] [varchar](20) NULL, 566 | [ContPrefix] [varchar](10) NULL, 567 | [ContSuffix] [varchar](10) NULL, 568 | [ContAddress1] [varchar](34) NULL, 569 | [ContAddress2] [varchar](34) NULL, 570 | [ContCity] [varchar](30) NULL, 571 | [ContState] [varchar](2) NULL, 572 | [ContZip] [varchar](9) NULL, 573 | [ElecCode] [varchar](5) NULL, 574 | [ElecOtherDesc] [varchar](20) NULL, 575 | [strContDate] [varchar](8) NULL, 576 | [ContAmount] [varchar](12) NULL, 577 | [ContAggregate] [varchar](12) NULL, 578 | [ContPurposeCode] [varchar](3) NULL, 579 | [ContPurposeDesc] [varchar](100) NULL, 580 | [ContEmployer] [varchar](38) NULL, 581 | [ContOccupation] [varchar](38) NULL, 582 | [DonorCommFECID] [varchar](9) NULL, 583 | [DonorCommName] [varchar](200) NULL, 584 | [DonorCandFECID] [varchar](9) NULL, 585 | [DonorCandLastName] [varchar](30) NULL, 586 | [DonorCandFirstName] [varchar](20) NULL, 587 | [DonorCandMidName] [varchar](20) NULL, 588 | [DonorCandPrefix] [varchar](10) NULL, 589 | [DonorCandSuffix] [varchar](10) NULL, 590 | [DonorCandOffice] [varchar](1) NULL, 591 | [DonorCandState] [varchar](2) NULL, 592 | [DonorCandDist] [varchar](2) NULL, 593 | [ConduitName] [varchar](200) NULL, 594 | [ConduitAddress1] [varchar](34) NULL, 595 | [ConduitAddress2] [varchar](34) NULL, 596 | [ConduitCity] [varchar](30) NULL, 597 | [ConduitState] [varchar](2) NULL, 598 | [ConduitZip] [varchar](9) NULL, 599 | [MemoCode] [varchar](1) NULL, 600 | [MemoText] [varchar](100) NULL 601 | ) ON [PRIMARY] 602 | GO 603 | 604 | -- Schedule B: 605 | CREATE TABLE [dbo].[Contribs_SchedB]( 606 | [USATID] [int] IDENTITY(1,1) NOT NULL, 607 | [ParentType] [varchar](5) NOT NULL, 608 | [ImageID] [int] NOT NULL, 609 | [FormType] [varchar](8) NOT NULL, 610 | [FilerCommID] [char](9) NOT NULL, 611 | [TransID] [varchar](20) NOT NULL, 612 | [BackRefTransID] [varchar](20) NULL, 613 | [BackRefSchedName] [varchar](8) NULL, 614 | [EntityType] [varchar](3) NULL, 615 | [PayeeOrgName] [varchar](200) NULL, 616 | [PayeeLastName] [varchar](30) NULL, 617 | [PayeeFirstName] [varchar](20) NULL, 618 | [PayeeMidName] [varchar](20) NULL, 619 | [PayeePrefix] [varchar](10) NULL, 620 | [PayeeSuffix] [varchar](10) NULL, 621 | [PayeeAddress1] [varchar](34) NULL, 622 | [PayeeAddress2] [varchar](34) NULL, 623 | [PayeeCity] [varchar](30) NULL, 624 | [PayeeState] [varchar](2) NULL, 625 | [PayeeZip] [varchar](9) NULL, 626 | [ElecCode] [varchar](5) NULL, 627 | [ElecOtherDesc] [varchar](20) NULL, 628 | [strExpDate] [varchar](8) NULL, 629 | [ExpAmount] [varchar](12) NULL, 630 | [SemiAnnRefundedBundledAmt] [varchar](12) NULL, 631 | [ExpPurpCode] [varchar](3) NULL, 632 | [ExpPurpDesc] [varchar](100) NULL, 633 | [CatCode] [varchar](3) NULL, 634 | [BenCommFECID] [varchar](9) NULL, 635 | [BenCommName] [varchar](200) NULL, 636 | [BenCandFECID] [varchar](9) NULL, 637 | [BenCandLastName] [varchar](30) NULL, 638 | [BenCandFirstName] [varchar](20) NULL, 639 | [BenCandMidName] [varchar](20) NULL, 640 | [BenCandPrefix] [varchar](10) NULL, 641 | [BenCandSuffix] [varchar](10) NULL, 642 | [BenCandOffice] [varchar](1) NULL, 643 | [BenCandState] [varchar](2) NULL, 644 | [BenCandDist] [varchar](2) NULL, 645 | [ConduitName] [varchar](200) NULL, 646 | [ConduitAddress1] [varchar](34) NULL, 647 | [ConduitAddress2] [varchar](34) NULL, 648 | [ConduitCity] [varchar](30) NULL, 649 | [ConduitState] [varchar](2) NULL, 650 | [ConduitZip] [varchar](9) NULL, 651 | [MemoCode] [varchar](1) NULL, 652 | [MemoText] [varchar](100) NULL 653 | ) ON [PRIMARY] 654 | 655 | GO 656 | 657 | -- Schedule C: 658 | CREATE TABLE [dbo].[Contribs_SchedC]( 659 | [USATID] [int] IDENTITY(1,1) NOT NULL, 660 | [ParentType] [varchar](5) NOT NULL, 661 | [ImageID] [int] NOT NULL, 662 | [FormType] [varchar](8) NOT NULL, 663 | [FilerCommID] [char](9) NOT NULL, 664 | [TransID] [varchar](20) NOT NULL, 665 | [RectLineNbr] [varchar](8) NULL, 666 | [EntityType] [varchar](3) NULL, 667 | [LenderOrgName] [varchar](200) NULL, 668 | [LenderLastName] [varchar](30) NULL, 669 | [LenderFirstName] [varchar](20) NULL, 670 | [LenderMidName] [varchar](20) NULL, 671 | [LenderPrefix] [varchar](10) NULL, 672 | [LenderSuffix] [varchar](10) NULL, 673 | [LenderAddress1] [varchar](34) NULL, 674 | [LenderAddress2] [varchar](34) NULL, 675 | [LenderCity] [varchar](30) NULL, 676 | [LenterState] [varchar](2) NULL, 677 | [LenderZip] [varchar](9) NULL, 678 | [ElecCod] [varchar](5) NULL, 679 | [ElecOtherDesc] [varchar](20) NULL, 680 | [LoanAmt] [varchar](12) NULL, 681 | [LoanPymtToDate] [varchar](12) NULL, 682 | [LoanBal] [varchar](12) NULL, 683 | [strLoanIncurredDate] [varchar](8) NULL, 684 | [strLoanDueDate] [varchar](15) NULL, 685 | [LoanIntRate] [varchar](15) NULL, 686 | [LoanSecuredFlag] [varchar](1) NULL, 687 | [LoanPersFundsFlag] [varchar](1) NULL, 688 | [LenderCommID] [varchar](9) NULL, 689 | [LenderCandID] [varchar](9) NULL, 690 | [LenderCandLastName] [varchar](30) NULL, 691 | [LenderCandFirstName] [varchar](20) NULL, 692 | [LenderCandMidName] [varchar](20) NULL, 693 | [LenderCandPrefix] [varchar](10) NULL, 694 | [LenderCandSuffix] [varchar](10) NULL, 695 | [LenderCandOffice] [varchar](1) NULL, 696 | [LenderCandState] [varchar](2) NULL, 697 | [LenderCandDist] [varchar](2) NULL, 698 | [MemoCode] [varchar](1) NULL, 699 | [MemoText] [varchar](100) NULL 700 | ) ON [PRIMARY] 701 | GO 702 | 703 | -- Schedule C1: 704 | CREATE TABLE [dbo].[Contribs_SchedC1]( 705 | [USATID] [int] IDENTITY(1,1) NOT NULL, 706 | [ParentType] [varchar](5) NOT NULL, 707 | [ImageID] [int] NOT NULL, 708 | [FormType] [varchar](8) NOT NULL, 709 | [FilerCommID] [char](9) NOT NULL, 710 | [TransID] [varchar](20) NOT NULL, 711 | [BackRefTransID] [varchar](20) NOT NULL, 712 | [LenderOrgName] [varchar](200) NULL, 713 | [LenderAddress1] [varchar](34) NULL, 714 | [LenderAddress2] [varchar](34) NULL, 715 | [LenderCity] [varchar](30) NULL, 716 | [LenderState] [varchar](2) NULL, 717 | [LenderZip] [varchar](9) NULL, 718 | [LoanAmt] [varchar](12) NULL, 719 | [LoanIntRate] [varchar](15) NULL, 720 | [strLoanIncurredDate] [varchar](8) NULL, 721 | [strLoanDueDate] [varchar](15) NULL, 722 | [A1_LoanRestructuredFlag] [varchar](1) NULL, 723 | [A2_strOrigLoanIncurredDate] [varchar](8) NULL, 724 | [B1_CreditAmtThisDraw] [varchar](12) NULL, 725 | [B2_TotBalance] [varchar](12) NULL, 726 | [C_OthersLiableFlag] [varchar](1) NULL, 727 | [D_CollateralFlag] [varchar](1) NULL, 728 | [D1_CollateralDescription] [varchar](100) NULL, 729 | [D2_CollateralValue] [varchar](12) NULL, 730 | [D3_PerfectedInterestFlag] [varchar](1) NULL, 731 | [E1_FutureIncomeFlag] [varchar](1) NULL, 732 | [E2_FutureIncomeDesc] [varchar](100) NULL, 733 | [E3_EstimatedValue] [varchar](12) NULL, 734 | [E4_strDepositoryAcctEstablishedDate] [varchar](8) NULL, 735 | [E5_AcctLocName] [varchar](200) NULL, 736 | [E6_AcctAddress1] [varchar](34) NULL, 737 | [E7_AcctAddress1] [varchar](34) NULL, 738 | [E8_AcctCity] [varchar](30) NULL, 739 | [E9_State] [varchar](2) NULL, 740 | [E10_Zip] [varchar](9) NULL, 741 | [E11_strDepositAcctAuthDate] [varchar](8) NULL, 742 | [F_LoanBasisDesc] [varchar](100) NULL, 743 | [G_TreasLastName] [varchar](30) NULL, 744 | [G_TreasFirstName] [varchar](20) NULL, 745 | [G_TreasMidName] [varchar](20) NULL, 746 | [G_TreasPrefix] [varchar](10) NULL, 747 | [G_TreasSuffix] [varchar](10) NULL, 748 | [G_strDateSigned] [varchar](8) NULL, 749 | [H_AuthorizedLastName] [varchar](30) NULL, 750 | [H_AuthorizedfirstName] [varchar](20) NULL, 751 | [H_AuthorizedMidName] [varchar](20) NULL, 752 | [H_AuthorizedPrefix] [varchar](10) NULL, 753 | [H_AuthorizedSuffix] [varchar](10) NULL, 754 | [H_AuthorizedTitle] [varchar](20) NULL, 755 | [H_strDateSigned] [varchar](8) NULL 756 | ) ON [PRIMARY] 757 | GO 758 | 759 | -- Schedule C2: 760 | CREATE TABLE [dbo].[Contribs_SchedC2]( 761 | [USATID] [int] IDENTITY(1,1) NOT NULL, 762 | [ParentType] [varchar](5) NOT NULL, 763 | [ImageID] [int] NOT NULL, 764 | [FormType] [varchar](8) NOT NULL, 765 | [FilerCommID] [char](9) NOT NULL, 766 | [TransID] [varchar](20) NOT NULL, 767 | [BackRefTransID] [varchar](20) NOT NULL, 768 | [GuarLastName] [varchar](30) NOT NULL, 769 | [GuarFirstName] [varchar](20) NOT NULL, 770 | [GuarMidName] [varchar](20) NULL, 771 | [GuarPrefix] [varchar](10) NULL, 772 | [GuarSuffix] [varchar](10) NULL, 773 | [GuarAddress1] [varchar](34) NULL, 774 | [GuarAddress2] [varchar](34) NULL, 775 | [GuarCity] [varchar](30) NULL, 776 | [GuarState] [varchar](2) NULL, 777 | [GuarZip] [varchar](9) NULL, 778 | [GuarEmployer] [varchar](38) NULL, 779 | [GuarOccupation] [varchar](38) NULL, 780 | [GuarAmt] [varchar](12) NULL 781 | ) ON [PRIMARY] 782 | GO 783 | 784 | -- Schedule D: 785 | CREATE TABLE [dbo].[Contribs_SchedD]( 786 | [USATID] [int] IDENTITY(1,1) NOT NULL, 787 | [ParentType] [varchar](5) NOT NULL, 788 | [ImageID] [int] NOT NULL, 789 | [FormType] [varchar](8) NOT NULL, 790 | [CommID] [char](9) NOT NULL, 791 | [TransID] [varchar](20) NOT NULL, 792 | [EntityType] [varchar](3) NOT NULL, 793 | [CredOrgName] [varchar](200) NULL, 794 | [CredLastName] [varchar](30) NOT NULL, 795 | [CredFirstName] [varchar](20) NULL, 796 | [CredMidName] [varchar](20) NULL, 797 | [CredPrefix] [varchar](10) NULL, 798 | [CredSuffix] [varchar](10) NULL, 799 | [CredAddress1] [varchar](34) NULL, 800 | [CredAddress2] [varchar](34) NULL, 801 | [CredCity] [varchar](30) NULL, 802 | [CredState] [varchar](2) NULL, 803 | [CredZip] [varchar](9) NULL, 804 | [DebtPurpose] [varchar](100) NULL, 805 | [BegBal_Prd] [varchar](12) NULL, 806 | [IncurredAmt_Prd] [varchar](12) NULL, 807 | [PaymtAmt_Prd] [varchar](12) NULL, 808 | [BalanceAtClose_Prd] [varchar](12) NULL 809 | ) ON [PRIMARY] 810 | GO 811 | 812 | -- Schedule E: 813 | CREATE TABLE [dbo].[Contribs_SchedE]( 814 | [USATID] [int] IDENTITY(1,1) NOT NULL, 815 | [ParentType] [varchar](5) NOT NULL, 816 | [ImageID] [int] NOT NULL, 817 | [FormType] [varchar](8) NOT NULL, 818 | [FilerCommID] [char](9) NOT NULL, 819 | [TransID] [varchar](20) NOT NULL, 820 | [BackRefTransID] [varchar](20) NULL, 821 | [BackRefSchedName] [varchar](8) NULL, 822 | [EntityType] [varchar](3) NULL, 823 | [PayeeOrgName] [varchar](200) NULL, 824 | [PayeeLastName] [varchar](30) NULL, 825 | [PayeeFirstName] [varchar](20) NULL, 826 | [PayeeMidName] [varchar](20) NULL, 827 | [PayeePrefix] [varchar](10) NULL, 828 | [PayeeSuffix] [varchar](10) NULL, 829 | [PayeeAddress1] [varchar](34) NULL, 830 | [PayeeAddress2] [varchar](34) NULL, 831 | [PayeeCity] [varchar](30) NULL, 832 | [PayeeState] [varchar](2) NULL, 833 | [PayeeZip] [varchar](9) NULL, 834 | [ElecCode] [varchar](5) NULL, 835 | [ElecOtherDesc] [varchar](20) NULL, 836 | [strExpDate] [varchar](8) NULL, 837 | [ExpAmount] [varchar](12) NULL, 838 | [CalYTD] [varchar](12) NULL, 839 | [ExpPurpCode] [varchar](3) NULL, 840 | [ExpPurpDesc] [varchar](100) NULL, 841 | [CatCode] [varchar](3) NULL, 842 | [PayeeCommFECID] [varchar](9) NULL, 843 | [SuppOppCode] [varchar](1) NULL, 844 | [SuppOppCandID] [varchar](9) NULL, 845 | [SuppOppCandLastName] [varchar](30) NULL, 846 | [SuppOppCandFirstName] [varchar](20) NULL, 847 | [SuppOppCandMidName] [varchar](20) NULL, 848 | [SuppOppCandPrefix] [varchar](10) NULL, 849 | [SuppOppCandSuffix] [varchar](10) NULL, 850 | [SuppOppCandOffice] [varchar](1) NULL, 851 | [SuppOppCandState] [varchar](2) NULL, 852 | [SuppOppCandDist] [varchar](2) NULL, 853 | [CompLastName] [varchar](30) NULL, 854 | [CompFirstName] [varchar](20) NULL, 855 | [CompMidName] [varchar](20) NULL, 856 | [CompPrefix] [varchar](10) NULL, 857 | [CompSuffix] [varchar](10) NULL, 858 | [strDateSigned] [varchar](8) NULL, 859 | [MemoCode] [varchar](1) NULL, 860 | [MemoText] [varchar](100) NULL 861 | ) ON [PRIMARY] 862 | GO 863 | 864 | -- Text records: 865 | CREATE TABLE [dbo].[Contribs_Text]( 866 | [USATID] [int] IDENTITY(1,1) NOT NULL, 867 | [ParentType] [varchar](5) NOT NULL, 868 | [ImageID] [int] NOT NULL, 869 | [RecType] [varchar](4) NOT NULL, 870 | [CommID] [char](9) NOT NULL, 871 | [TransID] [varchar](20) NOT NULL, 872 | [BackRefTransID] [varchar](20) NULL, 873 | [BackRefFormName] [varchar](8) NULL, 874 | [FullText] [varchar](4000) NULL 875 | ) ON [PRIMARY] 876 | GO 877 | 878 | SET ANSI_PADDING OFF 879 | GO 880 | 881 | 882 | -- Step 5: Create triggers 883 | -- Triggers are used to track when a report is amended. The active field is set to 1 for the current 884 | -- report and 0 for amended reports. 885 | CREATE TRIGGER [dbo].[UpdateF3Active] ON [dbo].[Contribs_FormF3] 886 | AFTER INSERT 887 | 888 | AS 889 | 890 | BEGIN 891 | SET NOCOUNT ON; 892 | 893 | UPDATE a 894 | SET a.Active = 0 895 | FROM Contribs_FormF3 a 896 | INNER JOIN Contribs_FormF3 b 897 | ON a.CommID = b.CommID 898 | AND a.ImageID < b.ImageID 899 | AND a.Active = 1 900 | AND b.Active = 1 901 | AND a.ReptCode = b.ReptCode 902 | AND a.strCovgFromDate = b.strCovgFromDate 903 | AND a.strCovgToDate = b.strCovgToDate; 904 | 905 | END 906 | GO 907 | 908 | 909 | 910 | CREATE TRIGGER [dbo].[UpdateF3PActive] ON [dbo].[Contribs_FormF3P] 911 | AFTER INSERT 912 | 913 | AS 914 | 915 | BEGIN 916 | SET NOCOUNT ON; 917 | 918 | UPDATE a 919 | SET a.Active = 0 920 | FROM Contribs_FormF3P a 921 | INNER JOIN Contribs_FormF3P b 922 | ON a.CommID = b.CommID 923 | AND a.ImageID < b.ImageID 924 | AND a.Active = 1 925 | AND b.Active = 1 926 | AND a.ReptCode = b.ReptCode 927 | AND a.strFromDate = b.strFromDate 928 | AND a.strToDate = b.strToDate; 929 | 930 | END 931 | GO 932 | 933 | 934 | 935 | CREATE TRIGGER [dbo].[UpdateF3XActive] ON [dbo].[Contribs_FormF3X] 936 | AFTER INSERT 937 | 938 | AS 939 | 940 | BEGIN 941 | SET NOCOUNT ON; 942 | 943 | UPDATE a 944 | SET a.Active = 0 945 | FROM Contribs_FormF3X a 946 | INNER JOIN Contribs_FormF3X b 947 | ON a.CommID = b.CommID 948 | AND a.ImageID < b.ImageID 949 | AND a.Active = 1 950 | AND b.Active = 1 951 | AND a.ReptCode = b.ReptCode 952 | AND a.strFromDate = b.strFromDate 953 | AND a.strToDate = b.strToDate; 954 | 955 | END 956 | GO 957 | 958 | 959 | 960 | -- Step 6: Create your stored procedures 961 | -- These stored procedures are called by the FEC Scraper Python script to determine 962 | -- previously downloaded committees and files. 963 | SET ANSI_NULLS ON 964 | GO 965 | 966 | SET QUOTED_IDENTIFIER ON 967 | GO 968 | 969 | -- This stored procedure retrieves Committee IDs that already exist in the database 970 | CREATE PROC [dbo].[usp_GetCommitteeIDs] 971 | 972 | AS 973 | 974 | SELECT CommID 975 | FROM Contribs_FormF3 976 | UNION 977 | SELECT CommID 978 | FROM Contribs_FormF3P 979 | UNION 980 | SELECT CommID 981 | FROM Contribs_FormF3X 982 | GROUP BY CommID; 983 | GO 984 | 985 | 986 | 987 | -- This stored procedure retrieves file IDs that already exist in the database 988 | CREATE PROC [dbo].[usp_GetFileIDs] 989 | 990 | AS 991 | 992 | SELECT ImageID 993 | FROM Contribs_FormF3 994 | UNION 995 | SELECT ImageID 996 | FROM Contribs_FormF3P 997 | UNION 998 | SELECT ImageID 999 | FROM Contribs_FormF3X; 1000 | 1001 | GO 1002 | 1003 | 1004 | 1005 | -- This stored procedure adds a header row to Contribs_FormF3 1006 | CREATE PROC [dbo].[usp_AddF3Header] (@ImageID varchar (9), @FormType char (4), @CommID char (9), 1007 | @CommName varchar (90), @AddressChange varchar (1), @CommAddress1 varchar (34), 1008 | @CommAddress2 varchar (34), @CommCity varchar (18), @CommState varchar (2), @CommZip varchar (9), 1009 | @ElecState varchar (2), @ElecDist varchar (2), @ReptCode varchar (3), @ElecCode varchar (5), 1010 | @strElecDate varchar (8), @StateOfElec varchar (2), @strCovgFromDate varchar (8), 1011 | @strCovgToDate varchar (8), @TreasLastName varchar (30), @TreasFirstName varchar (20), 1012 | @TreasMidName varchar (20), @TreasPrefix varchar (10), @TreasSuffix varchar (10), 1013 | @strDateSigned varchar (8), @Line6a_TotalContribs_Prd varchar (12), 1014 | @Line6b_TotalContribRefunds_Prd varchar (12), @Line6c_NetContribs_Prd varchar (12), 1015 | @Line7a_TotOpExps_Prd varchar (12), @Line7b_TotOffsetToOpExps_Prd varchar (12), 1016 | @Line7c_NetOpExps_Prd varchar (12), @Line8_CashOnHandAtClose_Prd varchar (12), 1017 | @Line9_DebtsTo_Prd varchar (12), @Line10_DebtsBy_Prd varchar (12), 1018 | @Line11a1_IndivsItemized_Prd varchar (12), @Line11a2_IndivsUnitemized_Prd varchar (12), 1019 | @Line11a3_IndivsContribTotal_Prd varchar (12), @Line11b_PolPtyComms_Prd varchar (12), 1020 | @Line11c_OtherPACs_Prd varchar (12), @Line11d_Candidate_Prd varchar (12), 1021 | @Line11e_TotalContribs_Prd varchar (12), @Line12_TransfersFrom_Prd varchar (12), 1022 | @Line13a_LoansByCand_Prd varchar (12), @Line13b_OtherLoans_Prd varchar (12), 1023 | @Line13c_TotLoans_Prd varchar (12), @Line14_OffsetsToOpExps_Prd varchar (12), 1024 | @Line15_OtherReceipts_Prd varchar (12), @Line16_TotReceipts_Prd varchar (12), 1025 | @Line17_OpExps_Prd varchar (12), @Line18_TransToOtherComms_Prd varchar (12), 1026 | @Line19a_LoanRepaymts_Cand_Prd varchar (12), @Line19b_LoanRepaymts_Other_Prd varchar (12), 1027 | @Line19c_TotLoanRepaymts_Prd varchar (12), @Loan20a_IndivRefunds_Prd varchar (12), 1028 | @Line20b_PolPartyCommRefunds_Prd varchar (12), @Line20c_OtherPolCommRefunds_Prd varchar (12), 1029 | @Line20d_TotContRefunds_Prd varchar (12), @Line21_OtherDisb_Prd varchar (12), 1030 | @Line22_TotDisb_Prd varchar (12), @Line23_CashBegin_Prd varchar (12), 1031 | @Line24_TotReceipts_Prd varchar (12), @Line25_Subtotal varchar (12), 1032 | @Line26_TotDisbThisPrd_Prd varchar (12), @Line27_CashAtClose_Prd varchar (12), 1033 | @Line6a_TotalContribs_Tot varchar (12), @Line6b_TotalContribRefunds_Tot varchar (12), 1034 | @Line6c_NetContribs_Tot varchar (12), @Line7a_TotOpExps_Tot varchar (12), 1035 | @Line7b_TotOffsetToOpExps_Tot varchar (12), @Line7c_NetOpExps_Tot varchar (12), 1036 | @Line11a1_IndivsItemized_Tot varchar (12), @Line11a2_IndivsUnitemized_Tot varchar (12), 1037 | @Line11a3_IndivsContribTotal_Tot varchar (12), @Line11b_PolPtyComms_Tot varchar (12), 1038 | @Line11c_OtherPACs_Tot varchar (12), @Line11d_Candidate_Tot varchar (12), 1039 | @Line11e_TotalContribs_Tot varchar (12), @Line12_TransfersFrom_Tot varchar (12), 1040 | @Line13a_LoansByCand_Tot varchar (12), @Line13b_OtherLoans_Tot varchar (12), 1041 | @Line13c_TotLoans_Tot varchar (12), @Line14_OffsetsToOpExps_Tot varchar (12), 1042 | @Line15_OtherReceipts_Tot varchar (12), @Line16_TotReceipts_Tot varchar (12), 1043 | @Line17_OpExps_Tot varchar (12), @Line18_TransToOtherComms_Tot varchar (12), 1044 | @Line19a_LoanRepaymts_Cand_Tot varchar (12), @Line19b_LoanRepaymts_Other_Tot varchar (12), 1045 | @Line19c_TotLoanRepaymts_Tot varchar (12), @Loan20a_IndivRefunds_Tot varchar (12), 1046 | @Line20b_PolPartyCommRefunds_Tot varchar (12), @Line20c_OtherPolCommRefunds_Tot varchar (12), 1047 | @Line20d_TotContRefunds_Tot varchar (12), @Line21_OtherDisb_Tot varchar (12), 1048 | @Line22_TotDisb_Tot varchar (12)) 1049 | 1050 | AS 1051 | 1052 | SET NOCOUNT ON 1053 | 1054 | -- See if this file already has been imported 1055 | -- If so, return -1 1056 | IF EXISTS 1057 | (SELECT ImageID 1058 | FROM dbo.Contribs_FormF3 1059 | WHERE ImageID = @ImageID) 1060 | BEGIN 1061 | SELECT -1; 1062 | RETURN 0; 1063 | END 1064 | 1065 | -- Otherwise, insert the header 1066 | INSERT INTO dbo.Contribs_FormF3 ([ImageID], [FormType], [CommID], [CommName], [AddressChange], 1067 | [CommAddress1], [CommAddress2], [CommCity], [CommState], [CommZip], [ElecState], [ElecDist], 1068 | [ReptCode], [ElecCode], [strElecDate], [StateOfElec], [strCovgFromDate], [strCovgToDate], 1069 | [TreasLastName], [TreasFirstName], [TreasMidName], [TreasPrefix], [TreasSuffix], [strDateSigned], 1070 | [Line6a_TotalContribs_Prd], [Line6b_TotalContribRefunds_Prd], [Line6c_NetContribs_Prd], 1071 | [Line7a_TotOpExps_Prd], [Line7b_TotOffsetToOpExps_Prd], [Line7c_NetOpExps_Prd], 1072 | [Line8_CashOnHandAtClose_Prd], [Line9_DebtsTo_Prd], [Line10_DebtsBy_Prd], 1073 | [Line11a1_IndivsItemized_Prd], [Line11a2_IndivsUnitemized_Prd], [Line11a3_IndivsContribTotal_Prd], 1074 | [Line11b_PolPtyComms_Prd], [Line11c_OtherPACs_Prd], [Line11d_Candidate_Prd], 1075 | [Line11e_TotalContribs_Prd], [Line12_TransfersFrom_Prd], [Line13a_LoansByCand_Prd], 1076 | [Line13b_OtherLoans_Prd], [Line13c_TotLoans_Prd], [Line14_OffsetsToOpExps_Prd], 1077 | [Line15_OtherReceipts_Prd], [Line16_TotReceipts_Prd], [Line17_OpExps_Prd], 1078 | [Line18_TransToOtherComms_Prd], [Line19a_LoanRepaymts_Cand_Prd], [Line19b_LoanRepaymts_Other_Prd], 1079 | [Line19c_TotLoanRepaymts_Prd], [Loan20a_IndivRefunds_Prd], [Line20b_PolPartyCommRefunds_Prd], 1080 | [Line20c_OtherPolCommRefunds_Prd], [Line20d_TotContRefunds_Prd], [Line21_OtherDisb_Prd], 1081 | [Line22_TotDisb_Prd], [Line23_CashBegin_Prd], [Line24_TotReceipts_Prd], [Line25_Subtotal], 1082 | [Line26_TotDisbThisPrd_Prd], [Line27_CashAtClose_Prd], [Line6a_TotalContribs_Tot], 1083 | [Line6b_TotalContribRefunds_Tot], [Line6c_NetContribs_Tot], [Line7a_TotOpExps_Tot], 1084 | [Line7b_TotOffsetToOpExps_Tot], [Line7c_NetOpExps_Tot], [Line11a1_IndivsItemized_Tot], 1085 | [Line11a2_IndivsUnitemized_Tot], [Line11a3_IndivsContribTotal_Tot], [Line11b_PolPtyComms_Tot], 1086 | [Line11c_OtherPACs_Tot], [Line11d_Candidate_Tot], [Line11e_TotalContribs_Tot], 1087 | [Line12_TransfersFrom_Tot], [Line13a_LoansByCand_Tot], [Line13b_OtherLoans_Tot], 1088 | [Line13c_TotLoans_Tot], [Line14_OffsetsToOpExps_Tot], [Line15_OtherReceipts_Tot], 1089 | [Line16_TotReceipts_Tot], [Line17_OpExps_Tot], [Line18_TransToOtherComms_Tot], 1090 | [Line19a_LoanRepaymts_Cand_Tot], [Line19b_LoanRepaymts_Other_Tot], [Line19c_TotLoanRepaymts_Tot], 1091 | [Loan20a_IndivRefunds_Tot], [Line20b_PolPartyCommRefunds_Tot], [Line20c_OtherPolCommRefunds_Tot], 1092 | [Line20d_TotContRefunds_Tot], [Line21_OtherDisb_Tot], [Line22_TotDisb_Tot]) 1093 | VALUES (@ImageID, @FormType, @CommID, @CommName, @AddressChange, 1094 | @CommAddress1, @CommAddress2, @CommCity, @CommState, @CommZip, @ElecState, @ElecDist, 1095 | @ReptCode, @ElecCode, @strElecDate, @StateOfElec, @strCovgFromDate, @strCovgToDate, 1096 | @TreasLastName, @TreasFirstName, @TreasMidName, @TreasPrefix, @TreasSuffix, @strDateSigned, 1097 | @Line6a_TotalContribs_Prd, @Line6b_TotalContribRefunds_Prd, @Line6c_NetContribs_Prd, 1098 | @Line7a_TotOpExps_Prd, @Line7b_TotOffsetToOpExps_Prd, @Line7c_NetOpExps_Prd, 1099 | @Line8_CashOnHandAtClose_Prd, @Line9_DebtsTo_Prd, @Line10_DebtsBy_Prd, 1100 | @Line11a1_IndivsItemized_Prd, @Line11a2_IndivsUnitemized_Prd, @Line11a3_IndivsContribTotal_Prd, 1101 | @Line11b_PolPtyComms_Prd, @Line11c_OtherPACs_Prd, @Line11d_Candidate_Prd, 1102 | @Line11e_TotalContribs_Prd, @Line12_TransfersFrom_Prd, @Line13a_LoansByCand_Prd, 1103 | @Line13b_OtherLoans_Prd, @Line13c_TotLoans_Prd, @Line14_OffsetsToOpExps_Prd, 1104 | @Line15_OtherReceipts_Prd, @Line16_TotReceipts_Prd, @Line17_OpExps_Prd, 1105 | @Line18_TransToOtherComms_Prd, @Line19a_LoanRepaymts_Cand_Prd, @Line19b_LoanRepaymts_Other_Prd, 1106 | @Line19c_TotLoanRepaymts_Prd, @Loan20a_IndivRefunds_Prd, @Line20b_PolPartyCommRefunds_Prd, 1107 | @Line20c_OtherPolCommRefunds_Prd, @Line20d_TotContRefunds_Prd, @Line21_OtherDisb_Prd, 1108 | @Line22_TotDisb_Prd, @Line23_CashBegin_Prd, @Line24_TotReceipts_Prd, @Line25_Subtotal, 1109 | @Line26_TotDisbThisPrd_Prd, @Line27_CashAtClose_Prd, @Line6a_TotalContribs_Tot, 1110 | @Line6b_TotalContribRefunds_Tot, @Line6c_NetContribs_Tot, @Line7a_TotOpExps_Tot, 1111 | @Line7b_TotOffsetToOpExps_Tot, @Line7c_NetOpExps_Tot, @Line11a1_IndivsItemized_Tot, 1112 | @Line11a2_IndivsUnitemized_Tot, @Line11a3_IndivsContribTotal_Tot, @Line11b_PolPtyComms_Tot, 1113 | @Line11c_OtherPACs_Tot, @Line11d_Candidate_Tot, @Line11e_TotalContribs_Tot, 1114 | @Line12_TransfersFrom_Tot, @Line13a_LoansByCand_Tot, @Line13b_OtherLoans_Tot, 1115 | @Line13c_TotLoans_Tot, @Line14_OffsetsToOpExps_Tot, @Line15_OtherReceipts_Tot, 1116 | @Line16_TotReceipts_Tot, @Line17_OpExps_Tot, @Line18_TransToOtherComms_Tot, 1117 | @Line19a_LoanRepaymts_Cand_Tot, @Line19b_LoanRepaymts_Other_Tot, @Line19c_TotLoanRepaymts_Tot, 1118 | @Loan20a_IndivRefunds_Tot, @Line20b_PolPartyCommRefunds_Tot, @Line20c_OtherPolCommRefunds_Tot, 1119 | @Line20d_TotContRefunds_Tot, @Line21_OtherDisb_Tot, @Line22_TotDisb_Tot); 1120 | 1121 | -- Return value to show new header row added. 1122 | SELECT 0; 1123 | RETURN 0; 1124 | 1125 | SET NOCOUNT OFF 1126 | GO 1127 | 1128 | 1129 | 1130 | -- This stored procedure adds a header row to Contribs_FormF3P 1131 | CREATE PROC [dbo].[usp_AddF3PHeader] (@ImageID varchar (9), @FormType char (4), @CommID char (9), 1132 | @CommName varchar (90), @AddressChange varchar (1), @CommAddress1 varchar (34), 1133 | @CommAddress2 varchar (34), @CommCity varchar (18), @CommState varchar (2), @CommZip varchar (9), 1134 | @ActivityPrim varchar (1), @ActivityGen varchar (1), @ReptCode varchar (3), @ElecCode varchar (5), 1135 | @strElecDate varchar (8), @ElecState varchar (2), @strFromDate varchar (8), @strToDate varchar (8), 1136 | @TreasLastName varchar (30), @TreasFirstName varchar (20), @TreasMidName varchar (20), 1137 | @TreasPrefix varchar (10), @TreasSuffix varchar (10), @strDateSigned char (8), 1138 | @Line6_CashBegin varchar (12), @Line7_TotReceipts varchar (12), @Line8_Subtotal varchar (12), 1139 | @Line9_TotalDisb varchar (12), @Line10_CashClose varchar (12), @Line11_DebtsTo varchar (12), 1140 | @Line12_DebtsBy varchar (12), @Line13_ExpendsSubToLimits varchar (12), 1141 | @Line14_NetContribs varchar (12), @Line15_NetOpExps varchar (12), @Line16_FedFunds_Prd varchar (12), 1142 | @Line17a1_IndivsItemzd_Prd varchar (12), @Line17a2_IndivsUnItemzd_Prd varchar (12), 1143 | @Line17a3_IndContTot_Prd varchar (12), @Line17b_PolPartyComms_Prd varchar (12), 1144 | @Line17c_OtherPACs_Prd varchar (12), @Line17d_Candidate_Prd varchar (12), 1145 | @Line17e_TotContribs_Prd varchar (12), @Line18_TransfersFrom_Prd varchar (12), 1146 | @Line19a_CandLoans_Prd varchar (12), @Line19b_OtherLoans_Prd varchar (12), 1147 | @Line19c_TotLoans_Prd varchar (12), @Line20a_Operating_Prd varchar (12), 1148 | @Line20b_Fundraising_Prd varchar (12), @Line20c_LegalAcctg_Prd varchar (12), 1149 | @Line20d_TotExpOffsets_Prd varchar (12), @Line21_OtherReceipts_Prd varchar (12), 1150 | @Line22_TotReceipts_Prd varchar (12), @Line23_OpExpends_Prd varchar (12), 1151 | @Line24_TransToOtherComms_Prd varchar (12), @Line25_FundraisingDisbursed_Prd varchar (12), 1152 | @Line26_ExemptLegalAcctgDisb_Prd varchar (12), @Line27a_CandRepymts_Prd varchar (12), 1153 | @Line27b_OtherRepymts_Prd varchar (12), @Line27c_TotLoanRepymts_Prd varchar (12), 1154 | @Line28a_IndivRefunds_Prd varchar (12), @Line28b_PolPartyCommRefunds_Prd varchar (12), 1155 | @Line28c_OtherPolCommRefunds_Prd varchar (12), @Line28d_TotalContRefunds_Prd varchar (12), 1156 | @Line29_OtherDisb_Prd varchar (12), @Line30_TotDisb_Prd varchar (12), 1157 | @Line31_ItemsToLiq_Prd varchar (12), @AllocAlabama_Prd varchar (12), 1158 | @AllocAlaska_Prd varchar (12), @AllocArizona_Prd varchar (12), @AllocArkansas_Prd varchar (12), 1159 | @AllocCalifornia_Prd varchar (12), @AllocColorado_Prd varchar (12), @AllocConnecticut_Prd varchar (12), 1160 | @AllocDelaware_Prd varchar (12), @AllocDistCol_Prd varchar (12), @AllocFlorida_Prd varchar (12), 1161 | @AllocGeorgia_Prd varchar (12), @AllocHawaii_Prd varchar (12), @AllocIdaho_Prd varchar (12), 1162 | @AllocIllinois_Prd varchar (12), @AllocIndiana_Prd varchar (12), @AllocIowa_Prd varchar (12), 1163 | @AllocKansas_Prd varchar (12), @AllocKentucky_Prd varchar (12), @AllocLouisiana_Prd varchar (12), 1164 | @AllocMaine_Prd varchar (12), @AllocMaryland_Prd varchar (12), @AllocMassachusetts_Prd varchar (12), 1165 | @AllocMichigan_Prd varchar (12), @AllocMinnesota_Prd varchar (12), @AllocMississippi_Prd varchar (12), 1166 | @AllocMissouri_Prd varchar (12), @AllocMontana_Prd varchar (12), @AllocNebraska_Prd varchar (12), 1167 | @AllocNevada_Prd varchar (12), @AllocNewHampshire_Prd varchar (12), @AllocNewJersey_Prd varchar (12), 1168 | @AllocNewMexico_Prd varchar (12), @AllocNewYork_Prd varchar (12), @AllocNorthCarolina_Prd varchar (12), 1169 | @AllocNorthDakota_Prd varchar (12), @AllocOhio_Prd varchar (12), @AllocOklahoma_Prd varchar (12), 1170 | @AllocOregon_Prd varchar (12), @AllocPennsylvania_Prd varchar (12), @AllocRhodeIsland_Prd varchar (12), 1171 | @AllocSouthCarolina_Prd varchar (12), @AllocSouthDakota_Prd varchar (12), 1172 | @AllocTennessee_Prd varchar (12), @AllocTexas_Prd varchar (12), @AllocUtah_Prd varchar (12), 1173 | @AllocVermont_Prd varchar (12), @AllocVirginia_Prd varchar (12), @AllocWashington_Prd varchar (12), 1174 | @AllocWestVirginia_Prd varchar (12), @AllocWisconsin_Prd varchar (12), @AllocWyoming_Prd varchar (12), 1175 | @AllocPuertoRico_Prd varchar (12), @AllocGuam_Prd varchar (12), @AllocVirginIslands_Prd varchar (12), 1176 | @AllocStatesTotal_Prd varchar (12), @Line16_FedFunds_Tot varchar (12), 1177 | @Line17a1_IndivsItemzd_Tot varchar (12), @Line17a2_IndivsUnItemzd_Tot varchar (12), 1178 | @Line17a3_IndContTot_Tot varchar (12), @Line17b_PolPartyComms_Tot varchar (12), 1179 | @Line17c_OtherPACs_Tot varchar (12), @Line17d_Candidate_Tot varchar (12), 1180 | @Line17e_TotContribs_Tot varchar (12), @Line18_TransfersFrom_Tot varchar (12), 1181 | @Line19a_CandLoans_Tot varchar (12), @Line19b_OtherLoans_Tot varchar (12), 1182 | @Line19c_TotLoans_Tot varchar (12), @Line20a_Operating_Tot varchar (12), 1183 | @Line20b_Fundraising_Tot varchar (12), @Line20c_LegalAcctg_Tot varchar (12), 1184 | @Line20d_TotExpOffsets_Tot varchar (12), @Line21_OtherReceipts_Tot varchar (12), 1185 | @Line22_TotReceipts_Tot varchar (12), @Line23_OpExpends_Tot varchar (12), 1186 | @Line24_TransToOtherComms_Tot varchar (12), @Line25_FundraisingDisbursed_Tot varchar (12), 1187 | @Line26_ExemptLegalAcctgDisb_Tot varchar (12), @Line27a_CandRepymts_Tot varchar (12), 1188 | @Line27b_OtherRepymts_Tot varchar (12), @Line27c_TotLoanRepymts_Tot varchar (12), 1189 | @Line28a_IndivRefunds_Tot varchar (12), @Line28b_PolPartyCommRefunds_Tot varchar (12), 1190 | @Line28c_OtherPolCommRefunds_Tot varchar (12), @Line28d_TotalContRefunds_Tot varchar (12), 1191 | @Line29_OtherDisb_Tot varchar (12), @Line30_TotDisb_Tot varchar (12), @AllocAlabama_Tot varchar (12), 1192 | @AllocAlaska_Tot varchar (12), @AllocArizona_Tot varchar (12), @AllocArkansas_Tot varchar (12), 1193 | @AllocCalifornia_Tot varchar (12), @AllocColorado_Tot varchar (12), @AllocConnecticut_Tot varchar (12), 1194 | @AllocDelaware_Tot varchar (12), @AllocDistCol_Tot varchar (12), @AllocFlorida_Tot varchar (12), 1195 | @AllocGeorgia_Tot varchar (12), @AllocHawaii_Tot varchar (12), @AllocIdaho_Tot varchar (12), 1196 | @AllocIllinois_Tot varchar (12), @AllocIndiana_Tot varchar (12), @AllocIowa_Tot varchar (12), 1197 | @AllocKansas_Tot varchar (12), @AllocKentucky_Tot varchar (12), @AllocLouisiana_Tot varchar (12), 1198 | @AllocMaine_Tot varchar (12), @AllocMaryland_Tot varchar (12), @AllocMassachusetts_Tot varchar (12), 1199 | @AllocMichigan_Tot varchar (12), @AllocMinnesota_Tot varchar (12), @AllocMississippi_Tot varchar (12), 1200 | @AllocMissouri_Tot varchar (12), @AllocMontana_Tot varchar (12), @AllocNebraska_Tot varchar (12), 1201 | @AllocNevada_Tot varchar (12), @AllocNewHampshire_Tot varchar (12), @AllocNewJersey_Tot varchar (12), 1202 | @AllocNewMexico_Tot varchar (12), @AllocNewYork_Tot varchar (12), @AllocNorthCarolina_Tot varchar (12), 1203 | @AllocNorthDakota_Tot varchar (12), @AllocOhio_Tot varchar (12), @AllocOklahoma_Tot varchar (12), 1204 | @AllocOregon_Tot varchar (12), @AllocPennsylvania_Tot varchar (12), @AllocRhodeIsland_Tot varchar (12), 1205 | @AllocSouthCarolina_Tot varchar (12), @AllocSouthDakota_Tot varchar (12), 1206 | @AllocTennessee_Tot varchar (12), @AllocTexas_Tot varchar (12), @AllocUtah_Tot varchar (12), 1207 | @AllocVermont_Tot varchar (12), @AllocVirginia_Tot varchar (12), @AllocWashington_Tot varchar (12), 1208 | @AllocWestVirginia_Tot varchar (12), @AllocWisconsin_Tot varchar (12), @AllocWyoming_Tot varchar (12), 1209 | @AllocPuertoRico_Tot varchar (12), @AllocGuam_Tot varchar (12), @AllocVirginIslands_Tot varchar (12), 1210 | @AllocStatesTotal_Tot varchar (12)) 1211 | 1212 | AS 1213 | 1214 | SET NOCOUNT ON 1215 | 1216 | -- See if this file already has been imported 1217 | -- If so, return -1 1218 | IF EXISTS 1219 | (SELECT ImageID 1220 | FROM dbo.Contribs_FormF3P 1221 | WHERE ImageID = @ImageID) 1222 | BEGIN 1223 | SELECT -1; 1224 | RETURN 0; 1225 | END 1226 | 1227 | -- Otherwise, insert the header 1228 | INSERT INTO dbo.Contribs_FormF3P ([ImageID], [FormType], [CommID], [CommName], [AddressChange], 1229 | [CommAddress1], [CommAddress2], [CommCity], [CommState], [CommZip], [ActivityPrim], [ActivityGen], 1230 | [ReptCode], [ElecCode], [strElecDate], [ElecState], [strFromDate], [strToDate], [TreasLastName], 1231 | [TreasFirstName], [TreasMidName], [TreasPrefix], [TreasSuffix], [strDateSigned], [Line6_CashBegin], 1232 | [Line7_TotReceipts], [Line8_Subtotal], [Line9_TotalDisb], [Line10_CashClose], [Line11_DebtsTo], 1233 | [Line12_DebtsBy], [Line13_ExpendsSubToLimits], [Line14_NetContribs], [Line15_NetOpExps], 1234 | [Line16_FedFunds_Prd], [Line17a1_IndivsItemzd_Prd], [Line17a2_IndivsUnItemzd_Prd], 1235 | [Line17a3_IndContTot_Prd], [Line17b_PolPartyComms_Prd], [Line17c_OtherPACs_Prd], 1236 | [Line17d_Candidate_Prd], [Line17e_TotContribs_Prd], [Line18_TransfersFrom_Prd], 1237 | [Line19a_CandLoans_Prd], [Line19b_OtherLoans_Prd], [Line19c_TotLoans_Prd], [Line20a_Operating_Prd], 1238 | [Line20b_Fundraising_Prd], [Line20c_LegalAcctg_Prd], [Line20d_TotExpOffsets_Prd], 1239 | [Line21_OtherReceipts_Prd], [Line22_TotReceipts_Prd], [Line23_OpExpends_Prd], 1240 | [Line24_TransToOtherComms_Prd], [Line25_FundraisingDisbursed_Prd], [Line26_ExemptLegalAcctgDisb_Prd], 1241 | [Line27a_CandRepymts_Prd], [Line27b_OtherRepymts_Prd], [Line27c_TotLoanRepymts_Prd], 1242 | [Line28a_IndivRefunds_Prd], [Line28b_PolPartyCommRefunds_Prd], [Line28c_OtherPolCommRefunds_Prd], 1243 | [Line28d_TotalContRefunds_Prd], [Line29_OtherDisb_Prd], [Line30_TotDisb_Prd], [Line31_ItemsToLiq_Prd], 1244 | [AllocAlabama_Prd], [AllocAlaska_Prd], [AllocArizona_Prd], [AllocArkansas_Prd], [AllocCalifornia_Prd], 1245 | [AllocColorado_Prd], [AllocConnecticut_Prd], [AllocDelaware_Prd], [AllocDistCol_Prd], 1246 | [AllocFlorida_Prd], [AllocGeorgia_Prd], [AllocHawaii_Prd], [AllocIdaho_Prd], [AllocIllinois_Prd], 1247 | [AllocIndiana_Prd], [AllocIowa_Prd], [AllocKansas_Prd], [AllocKentucky_Prd], [AllocLouisiana_Prd], 1248 | [AllocMaine_Prd], [AllocMaryland_Prd], [AllocMassachusetts_Prd], [AllocMichigan_Prd], 1249 | [AllocMinnesota_Prd], [AllocMississippi_Prd], [AllocMissouri_Prd], [AllocMontana_Prd], 1250 | [AllocNebraska_Prd], [AllocNevada_Prd], [AllocNewHampshire_Prd], [AllocNewJersey_Prd], 1251 | [AllocNewMexico_Prd], [AllocNewYork_Prd], [AllocNorthCarolina_Prd], [AllocNorthDakota_Prd], 1252 | [AllocOhio_Prd], [AllocOklahoma_Prd], [AllocOregon_Prd], [AllocPennsylvania_Prd], 1253 | [AllocRhodeIsland_Prd], [AllocSouthCarolina_Prd], [AllocSouthDakota_Prd], [AllocTennessee_Prd], 1254 | [AllocTexas_Prd], [AllocUtah_Prd], [AllocVermont_Prd], [AllocVirginia_Prd], [AllocWashington_Prd], 1255 | [AllocWestVirginia_Prd], [AllocWisconsin_Prd], [AllocWyoming_Prd], [AllocPuertoRico_Prd], 1256 | [AllocGuam_Prd], [AllocVirginIslands_Prd], [AllocStatesTotal_Prd], [Line16_FedFunds_Tot], 1257 | [Line17a1_IndivsItemzd_Tot], [Line17a2_IndivsUnItemzd_Tot], [Line17a3_IndContTot_Tot], 1258 | [Line17b_PolPartyComms_Tot], [Line17c_OtherPACs_Tot], [Line17d_Candidate_Tot], 1259 | [Line17e_TotContribs_Tot], [Line18_TransfersFrom_Tot], [Line19a_CandLoans_Tot], 1260 | [Line19b_OtherLoans_Tot], [Line19c_TotLoans_Tot], [Line20a_Operating_Tot], [Line20b_Fundraising_Tot], 1261 | [Line20c_LegalAcctg_Tot], [Line20d_TotExpOffsets_Tot], [Line21_OtherReceipts_Tot], 1262 | [Line22_TotReceipts_Tot], [Line23_OpExpends_Tot], [Line24_TransToOtherComms_Tot], 1263 | [Line25_FundraisingDisbursed_Tot], [Line26_ExemptLegalAcctgDisb_Tot], [Line27a_CandRepymts_Tot], 1264 | [Line27b_OtherRepymts_Tot], [Line27c_TotLoanRepymts_Tot], [Line28a_IndivRefunds_Tot], 1265 | [Line28b_PolPartyCommRefunds_Tot], [Line28c_OtherPolCommRefunds_Tot], [Line28d_TotalContRefunds_Tot], 1266 | [Line29_OtherDisb_Tot], [Line30_TotDisb_Tot], [AllocAlabama_Tot], [AllocAlaska_Tot], 1267 | [AllocArizona_Tot], [AllocArkansas_Tot], [AllocCalifornia_Tot], [AllocColorado_Tot], 1268 | [AllocConnecticut_Tot], [AllocDelaware_Tot], [AllocDistCol_Tot], [AllocFlorida_Tot], 1269 | [AllocGeorgia_Tot], [AllocHawaii_Tot], [AllocIdaho_Tot], [AllocIllinois_Tot], [AllocIndiana_Tot], 1270 | [AllocIowa_Tot], [AllocKansas_Tot], [AllocKentucky_Tot], [AllocLouisiana_Tot], [AllocMaine_Tot], 1271 | [AllocMaryland_Tot], [AllocMassachusetts_Tot], [AllocMichigan_Tot], [AllocMinnesota_Tot], 1272 | [AllocMississippi_Tot], [AllocMissouri_Tot], [AllocMontana_Tot], [AllocNebraska_Tot], 1273 | [AllocNevada_Tot], [AllocNewHampshire_Tot], [AllocNewJersey_Tot], [AllocNewMexico_Tot], 1274 | [AllocNewYork_Tot], [AllocNorthCarolina_Tot], [AllocNorthDakota_Tot], [AllocOhio_Tot], 1275 | [AllocOklahoma_Tot], [AllocOregon_Tot], [AllocPennsylvania_Tot], [AllocRhodeIsland_Tot], 1276 | [AllocSouthCarolina_Tot], [AllocSouthDakota_Tot], [AllocTennessee_Tot], [AllocTexas_Tot], 1277 | [AllocUtah_Tot], [AllocVermont_Tot], [AllocVirginia_Tot], [AllocWashington_Tot], 1278 | [AllocWestVirginia_Tot], [AllocWisconsin_Tot], [AllocWyoming_Tot], [AllocPuertoRico_Tot], 1279 | [AllocGuam_Tot], [AllocVirginIslands_Tot], [AllocStatesTotal_Tot]) 1280 | VALUES (@ImageID, @FormType, @CommID, @CommName, @AddressChange, @CommAddress1, @CommAddress2, 1281 | @CommCity, @CommState, @CommZip, @ActivityPrim, @ActivityGen, @ReptCode, @ElecCode, @strElecDate, 1282 | @ElecState, @strFromDate, @strToDate, @TreasLastName, @TreasFirstName, @TreasMidName, @TreasPrefix, 1283 | @TreasSuffix, @strDateSigned, @Line6_CashBegin, @Line7_TotReceipts, @Line8_Subtotal, @Line9_TotalDisb, 1284 | @Line10_CashClose, @Line11_DebtsTo, @Line12_DebtsBy, @Line13_ExpendsSubToLimits, @Line14_NetContribs, 1285 | @Line15_NetOpExps, @Line16_FedFunds_Prd, @Line17a1_IndivsItemzd_Prd, @Line17a2_IndivsUnItemzd_Prd, 1286 | @Line17a3_IndContTot_Prd, @Line17b_PolPartyComms_Prd, @Line17c_OtherPACs_Prd, @Line17d_Candidate_Prd, 1287 | @Line17e_TotContribs_Prd, @Line18_TransfersFrom_Prd, @Line19a_CandLoans_Prd, @Line19b_OtherLoans_Prd, 1288 | @Line19c_TotLoans_Prd, @Line20a_Operating_Prd, @Line20b_Fundraising_Prd, @Line20c_LegalAcctg_Prd, 1289 | @Line20d_TotExpOffsets_Prd, @Line21_OtherReceipts_Prd, @Line22_TotReceipts_Prd, @Line23_OpExpends_Prd, 1290 | @Line24_TransToOtherComms_Prd, @Line25_FundraisingDisbursed_Prd, @Line26_ExemptLegalAcctgDisb_Prd, 1291 | @Line27a_CandRepymts_Prd, @Line27b_OtherRepymts_Prd, @Line27c_TotLoanRepymts_Prd, 1292 | @Line28a_IndivRefunds_Prd, @Line28b_PolPartyCommRefunds_Prd, @Line28c_OtherPolCommRefunds_Prd, 1293 | @Line28d_TotalContRefunds_Prd, @Line29_OtherDisb_Prd, @Line30_TotDisb_Prd, @Line31_ItemsToLiq_Prd, 1294 | @AllocAlabama_Prd, @AllocAlaska_Prd, @AllocArizona_Prd, @AllocArkansas_Prd, @AllocCalifornia_Prd, 1295 | @AllocColorado_Prd, @AllocConnecticut_Prd, @AllocDelaware_Prd, @AllocDistCol_Prd, @AllocFlorida_Prd, 1296 | @AllocGeorgia_Prd, @AllocHawaii_Prd, @AllocIdaho_Prd, @AllocIllinois_Prd, @AllocIndiana_Prd, 1297 | @AllocIowa_Prd, @AllocKansas_Prd, @AllocKentucky_Prd, @AllocLouisiana_Prd, @AllocMaine_Prd, 1298 | @AllocMaryland_Prd, @AllocMassachusetts_Prd, @AllocMichigan_Prd, @AllocMinnesota_Prd, 1299 | @AllocMississippi_Prd, @AllocMissouri_Prd, @AllocMontana_Prd, @AllocNebraska_Prd, @AllocNevada_Prd, 1300 | @AllocNewHampshire_Prd, @AllocNewJersey_Prd, @AllocNewMexico_Prd, @AllocNewYork_Prd, 1301 | @AllocNorthCarolina_Prd, @AllocNorthDakota_Prd, @AllocOhio_Prd, @AllocOklahoma_Prd, @AllocOregon_Prd, 1302 | @AllocPennsylvania_Prd, @AllocRhodeIsland_Prd, @AllocSouthCarolina_Prd, @AllocSouthDakota_Prd, 1303 | @AllocTennessee_Prd, @AllocTexas_Prd, @AllocUtah_Prd, @AllocVermont_Prd, @AllocVirginia_Prd, 1304 | @AllocWashington_Prd, @AllocWestVirginia_Prd, @AllocWisconsin_Prd, @AllocWyoming_Prd, 1305 | @AllocPuertoRico_Prd, @AllocGuam_Prd, @AllocVirginIslands_Prd, @AllocStatesTotal_Prd, 1306 | @Line16_FedFunds_Tot, @Line17a1_IndivsItemzd_Tot, @Line17a2_IndivsUnItemzd_Tot, 1307 | @Line17a3_IndContTot_Tot, @Line17b_PolPartyComms_Tot, @Line17c_OtherPACs_Tot, @Line17d_Candidate_Tot, 1308 | @Line17e_TotContribs_Tot, @Line18_TransfersFrom_Tot, @Line19a_CandLoans_Tot, @Line19b_OtherLoans_Tot, 1309 | @Line19c_TotLoans_Tot, @Line20a_Operating_Tot, @Line20b_Fundraising_Tot, @Line20c_LegalAcctg_Tot, 1310 | @Line20d_TotExpOffsets_Tot, @Line21_OtherReceipts_Tot, @Line22_TotReceipts_Tot, @Line23_OpExpends_Tot, 1311 | @Line24_TransToOtherComms_Tot, @Line25_FundraisingDisbursed_Tot, @Line26_ExemptLegalAcctgDisb_Tot, 1312 | @Line27a_CandRepymts_Tot, @Line27b_OtherRepymts_Tot, @Line27c_TotLoanRepymts_Tot, 1313 | @Line28a_IndivRefunds_Tot, @Line28b_PolPartyCommRefunds_Tot, @Line28c_OtherPolCommRefunds_Tot, 1314 | @Line28d_TotalContRefunds_Tot, @Line29_OtherDisb_Tot, @Line30_TotDisb_Tot, @AllocAlabama_Tot, 1315 | @AllocAlaska_Tot, @AllocArizona_Tot, @AllocArkansas_Tot, @AllocCalifornia_Tot, @AllocColorado_Tot, 1316 | @AllocConnecticut_Tot, @AllocDelaware_Tot, @AllocDistCol_Tot, @AllocFlorida_Tot, @AllocGeorgia_Tot, 1317 | @AllocHawaii_Tot, @AllocIdaho_Tot, @AllocIllinois_Tot, @AllocIndiana_Tot, @AllocIowa_Tot, 1318 | @AllocKansas_Tot, @AllocKentucky_Tot, @AllocLouisiana_Tot, @AllocMaine_Tot, @AllocMaryland_Tot, 1319 | @AllocMassachusetts_Tot, @AllocMichigan_Tot, @AllocMinnesota_Tot, @AllocMississippi_Tot, 1320 | @AllocMissouri_Tot, @AllocMontana_Tot, @AllocNebraska_Tot, @AllocNevada_Tot, @AllocNewHampshire_Tot, 1321 | @AllocNewJersey_Tot, @AllocNewMexico_Tot, @AllocNewYork_Tot, @AllocNorthCarolina_Tot, 1322 | @AllocNorthDakota_Tot, @AllocOhio_Tot, @AllocOklahoma_Tot, @AllocOregon_Tot, @AllocPennsylvania_Tot, 1323 | @AllocRhodeIsland_Tot, @AllocSouthCarolina_Tot, @AllocSouthDakota_Tot, @AllocTennessee_Tot, 1324 | @AllocTexas_Tot, @AllocUtah_Tot, @AllocVermont_Tot, @AllocVirginia_Tot, @AllocWashington_Tot, 1325 | @AllocWestVirginia_Tot, @AllocWisconsin_Tot, @AllocWyoming_Tot, @AllocPuertoRico_Tot, @AllocGuam_Tot, 1326 | @AllocVirginIslands_Tot, @AllocStatesTotal_Tot); 1327 | 1328 | -- Return value to show new header row added. 1329 | SELECT 0; 1330 | RETURN 0; 1331 | 1332 | SET NOCOUNT OFF 1333 | GO 1334 | 1335 | 1336 | 1337 | -- This stored procedure adds a header row to Contribs_FormF3X 1338 | CREATE PROC [dbo].[usp_AddF3XHeader] (@ImageID varchar (9), @FormType char (4), @CommID char (9), 1339 | @CommName varchar (90), @AddressChange varchar (1), @CommAddress1 varchar (34), 1340 | @CommAddress2 varchar (34), @CommCity varchar (18), @CommState varchar (2), @CommZip varchar (9), 1341 | @ReptCode varchar (3), @ElecCode varchar (5), @strElecDate varchar (8), @ElecState varchar (2), 1342 | @strFromDate varchar (8), @strToDate varchar (8), @flgQualifiedComm varchar (1), 1343 | @TreasLastName varchar (30), @TreasFirstName varchar (20), @TreasMidName varchar (20), 1344 | @TreasPrefix varchar (10), @TreasSuffix varchar (10), @strDateSigned char (8), 1345 | @Line6b_CashBegin_Prd varchar (12), @Line6c_TotalRects_Prd varchar (12), 1346 | @Line6d_CashBeginSubtotal_Prd varchar (12), @Line7_TotDisbmts_Prd varchar (12), 1347 | @Line8_CashOnHandAtClose_Prd varchar (12), @Line9_DebtsTo_Prd varchar (12), 1348 | @Line10_DebtsBy_Prd varchar (12), @Line11a1_Itemized_Prd varchar (12), 1349 | @Line11a2_Unitemized_Prd varchar (12), @Line11a3_Total_Prd varchar (12), 1350 | @Line11b_PolPtyComms_Prd varchar (12), @Line11c_OtherPACs_Prd varchar (12), 1351 | @Line11d_TotalContribs_Prd varchar (12), @Line12_TransfersFrom_Prd varchar (12), 1352 | @Line13_AllLoansRcvd_Prd varchar (12), @Line14_LoanRepymtsRecv_Prd varchar (12), 1353 | @Line15_OffsetsToOpExps_Refunds_Prd varchar (12), @Line16_RefundsOfFedContribs_Prd varchar (12), 1354 | @Line17_OtherFedRects_Divds_Prd varchar (12), @Line18a_TransfersFromNonFedAcct_H3_Prd varchar (12), 1355 | @Line18b_TransfersFromNonFed_LevinH5_Prd varchar (12), @Line18c_TotalNonFedTransfers_Prd varchar (12), 1356 | @Line19_TotalReceipts_Prd varchar (12), @Line20_TotalFedReceipts_Prd varchar (12), 1357 | @Line21a1_FedShare_Prd varchar (12), @Line21a2_NonFedShare_Prd varchar (12), 1358 | @Line21b_OtherFedOpExps_Prd varchar (12), @Line21c_TotOpExps_Prd varchar (12), 1359 | @Line22_TransToOtherComms_Prd varchar (12), @Line23_ContribsToFedCandsOrComms_Prd varchar (12), 1360 | @Line24_IndptExps_Prd varchar (12), @Line25_CoordtdExpByPrtyComms_Prd varchar (12), 1361 | @Line26_LoanRepayments_Prd varchar (12), @Line27_LoansMade_Prd varchar (12), 1362 | @Line28a_IndivRefunds_Prd varchar (12), @Line28b_PolPartyCommRefunds_Prd varchar (12), 1363 | @Line28c_OtherPolCommRefunds_Prd varchar (12), @Line28d_TotalContRefunds_Prd varchar (12), 1364 | @Line29_OtherDisb_Prd varchar (12), @Line30a1_SharedFedActH6FedShare_Prd varchar (12), 1365 | @Line30a2_SharedFedActH6NonFed_Prd varchar (12), 1366 | @Line30b_NonAlloc100PctFedElecActivity_Prd varchar (12), @Line30c_TotFedElecActivity_Prd varchar (12), 1367 | @Line31_TotDisbmts_Prd varchar (12), @Line32_TotFedDisbmts_Prd varchar (12), 1368 | @Line33_TotContribs_Prd varchar (12), @Line34_TotContribRefunds_Prd varchar (12), 1369 | @Line35_NetContribs_Prd varchar (12), @Line36_TotFedOpExps_Prd varchar (12), 1370 | @Line37_OffsetsToOpExps_Prd varchar (12), @Line38_NetOpExps_Prd varchar (12), 1371 | @Line6b_CashBegin_Tot varchar (12), @Line6b_Year varchar (12), @Line6c_TotalRects_Tot varchar (12), 1372 | @Line6d_CashBeginSubtotal_Tot varchar (12), @Line7_TotDisbmts_Tot varchar (12), 1373 | @Line8_CashOnHandAtClose_Tot varchar (12), @Line11a1_Itemized_Tot varchar (12), 1374 | @Line11a2_Unitemized_Tot varchar (12), @Line11a3_Total_Tot varchar (12), 1375 | @Line11b_PolPtyComms_Tot varchar (12), @Line11c_OtherPACs_Tot varchar (12), 1376 | @Line11d_TotalContribs_Tot varchar (12), @Line12_TransfersFrom_Tot varchar (12), 1377 | @Line13_AllLoansRcvd_Tot varchar (12), @Line14_LoanRepymtsRecv_Tot varchar (12), 1378 | @Line15_OffsetsToOpExps_Refunds_Tot varchar (12), @Line16_RefundsOfFedContribs_Tot varchar (12), 1379 | @Line17_OtherFedRects_Divds_Tot varchar (12), @Line18a_TransfersFromNonFedAcct_H3_Tot varchar (12), 1380 | @Line18b_TransfersFromNonFed_LevinH5_Tot varchar (12), @Line18c_TotalNonFedTransfers_Tot varchar (12), 1381 | @Line19_TotalReceipts_Tot varchar (12), @Line20_TotalFedReceipts_Tot varchar (12), 1382 | @Line21a1_FedShare_Tot varchar (12), @Line21a2_NonFedShare_Tot varchar (12), 1383 | @Line21b_OtherFedOpExps_Tot varchar (12), @Line21c_TotOpExps_Tot varchar (12), 1384 | @Line22_TransToOtherComms_Tot varchar (12), @Line23_ContribsToFedCandsOrComms_Tot varchar (12), 1385 | @Line24_IndptExps_Tot varchar (12), @Line25_CoordtdExpByPrtyComms_Tot varchar (12), 1386 | @Line26_LoanRepayments_Tot varchar (12), @Line27_LoansMade_Tot varchar (12), 1387 | @Line28a_IndivRefunds_Tot varchar (12), @Line28b_PolPartyCommRefunds_Tot varchar (12), 1388 | @Line28c_OtherPolCommRefunds_Tot varchar (12), @Line28d_TotalContRefunds_Tot varchar (12), 1389 | @Line29_OtherDisb_Tot varchar (12), @Line30a1_SharedFedActH6FedShare_Tot varchar (12), 1390 | @Line30a2_SharedFedActH6NonFed_Tot varchar (12), 1391 | @Line30b_NonAlloc100PctFedElecActivity_Tot varchar (12), @Line30c_TotFedElecActivity_Tot varchar (12), 1392 | @Line31_TotDisbmts_Tot varchar (12), @Line32_TotFedDisbmts_Tot varchar (12), 1393 | @Line33_TotContribs_Tot varchar (12), @Line34_TotContribRefunds_Tot varchar (12), 1394 | @Line35_NetContribs_Tot varchar (12), @Line36_TotFedOpExps_Tot varchar (12), 1395 | @Line37_OffsetsToOpExps_Tot varchar (12), @Line38_NetOpExps_Tot varchar (12)) 1396 | 1397 | AS 1398 | 1399 | SET NOCOUNT ON 1400 | 1401 | -- See if this file already has been imported 1402 | -- If so, return -1 1403 | IF EXISTS 1404 | (SELECT ImageID 1405 | FROM dbo.Contribs_FormF3X 1406 | WHERE ImageID = @ImageID) 1407 | BEGIN 1408 | SELECT -1; 1409 | RETURN 0; 1410 | END 1411 | 1412 | -- Otherwise, insert the header 1413 | INSERT INTO dbo.Contribs_FormF3X ([ImageID], [FormType], [CommID], [CommName], [AddressChange], 1414 | [CommAddress1], [CommAddress2], [CommCity], [CommState], [CommZip], [ReptCode], [ElecCode], 1415 | [strElecDate], [ElecState], [strFromDate], [strToDate], [flgQualifiedComm], [TreasLastName], 1416 | [TreasFirstName], [TreasMidName], [TreasPrefix], [TreasSuffix], [strDateSigned], [Line6b_CashBegin_Prd], 1417 | [Line6c_TotalRects_Prd], [Line6d_CashBeginSubtotal_Prd], [Line7_TotDisbmts_Prd], 1418 | [Line8_CashOnHandAtClose_Prd], [Line9_DebtsTo_Prd], [Line10_DebtsBy_Prd], [Line11a1_Itemized_Prd], 1419 | [Line11a2_Unitemized_Prd], [Line11a3_Total_Prd], [Line11b_PolPtyComms_Prd], [Line11c_OtherPACs_Prd], 1420 | [Line11d_TotalContribs_Prd], [Line12_TransfersFrom_Prd], [Line13_AllLoansRcvd_Prd], 1421 | [Line14_LoanRepymtsRecv_Prd], [Line15_OffsetsToOpExps_Refunds_Prd], [Line16_RefundsOfFedContribs_Prd], 1422 | [Line17_OtherFedRects_Divds_Prd], [Line18a_TransfersFromNonFedAcct_H3_Prd], 1423 | [Line18b_TransfersFromNonFed_LevinH5_Prd], [Line18c_TotalNonFedTransfers_Prd], 1424 | [Line19_TotalReceipts_Prd], [Line20_TotalFedReceipts_Prd], [Line21a1_FedShare_Prd], 1425 | [Line21a2_NonFedShare_Prd], [Line21b_OtherFedOpExps_Prd], [Line21c_TotOpExps_Prd], 1426 | [Line22_TransToOtherComms_Prd], [Line23_ContribsToFedCandsOrComms_Prd], [Line24_IndptExps_Prd], 1427 | [Line25_CoordtdExpByPrtyComms_Prd], [Line26_LoanRepayments_Prd], [Line27_LoansMade_Prd], 1428 | [Line28a_IndivRefunds_Prd], [Line28b_PolPartyCommRefunds_Prd], [Line28c_OtherPolCommRefunds_Prd], 1429 | [Line28d_TotalContRefunds_Prd], [Line29_OtherDisb_Prd], [Line30a1_SharedFedActH6FedShare_Prd], 1430 | [Line30a2_SharedFedActH6NonFed_Prd], [Line30b_NonAlloc100PctFedElecActivity_Prd], 1431 | [Line30c_TotFedElecActivity_Prd], [Line31_TotDisbmts_Prd], [Line32_TotFedDisbmts_Prd], 1432 | [Line33_TotContribs_Prd], [Line34_TotContribRefunds_Prd], [Line35_NetContribs_Prd], 1433 | [Line36_TotFedOpExps_Prd], [Line37_OffsetsToOpExps_Prd], [Line38_NetOpExps_Prd], 1434 | [Line6b_CashBegin_Tot], [Line6b_Year], [Line6c_TotalRects_Tot], [Line6d_CashBeginSubtotal_Tot], 1435 | [Line7_TotDisbmts_Tot], [Line8_CashOnHandAtClose_Tot], [Line11a1_Itemized_Tot], 1436 | [Line11a2_Unitemized_Tot], [Line11a3_Total_Tot], [Line11b_PolPtyComms_Tot], [Line11c_OtherPACs_Tot], 1437 | [Line11d_TotalContribs_Tot], [Line12_TransfersFrom_Tot], [Line13_AllLoansRcvd_Tot], 1438 | [Line14_LoanRepymtsRecv_Tot], [Line15_OffsetsToOpExps_Refunds_Tot], [Line16_RefundsOfFedContribs_Tot], 1439 | [Line17_OtherFedRects_Divds_Tot], [Line18a_TransfersFromNonFedAcct_H3_Tot], 1440 | [Line18b_TransfersFromNonFed_LevinH5_Tot], [Line18c_TotalNonFedTransfers_Tot], 1441 | [Line19_TotalReceipts_Tot], [Line20_TotalFedReceipts_Tot], [Line21a1_FedShare_Tot], 1442 | [Line21a2_NonFedShare_Tot], [Line21b_OtherFedOpExps_Tot], [Line21c_TotOpExps_Tot], 1443 | [Line22_TransToOtherComms_Tot], [Line23_ContribsToFedCandsOrComms_Tot], [Line24_IndptExps_Tot], 1444 | [Line25_CoordtdExpByPrtyComms_Tot], [Line26_LoanRepayments_Tot], [Line27_LoansMade_Tot], 1445 | [Line28a_IndivRefunds_Tot], [Line28b_PolPartyCommRefunds_Tot], [Line28c_OtherPolCommRefunds_Tot], 1446 | [Line28d_TotalContRefunds_Tot], [Line29_OtherDisb_Tot], [Line30a1_SharedFedActH6FedShare_Tot], 1447 | [Line30a2_SharedFedActH6NonFed_Tot], [Line30b_NonAlloc100PctFedElecActivity_Tot], 1448 | [Line30c_TotFedElecActivity_Tot], [Line31_TotDisbmts_Tot], [Line32_TotFedDisbmts_Tot], 1449 | [Line33_TotContribs_Tot], [Line34_TotContribRefunds_Tot], [Line35_NetContribs_Tot], 1450 | [Line36_TotFedOpExps_Tot], [Line37_OffsetsToOpExps_Tot], [Line38_NetOpExps_Tot]) 1451 | VALUES (@ImageID, @FormType, @CommID, @CommName, @AddressChange, @CommAddress1, @CommAddress2, 1452 | @CommCity, @CommState, @CommZip, @ReptCode, @ElecCode, @strElecDate, @ElecState, @strFromDate, 1453 | @strToDate, @flgQualifiedComm, @TreasLastName, @TreasFirstName, @TreasMidName, @TreasPrefix, 1454 | @TreasSuffix, @strDateSigned, @Line6b_CashBegin_Prd, @Line6c_TotalRects_Prd, 1455 | @Line6d_CashBeginSubtotal_Prd, @Line7_TotDisbmts_Prd, @Line8_CashOnHandAtClose_Prd, @Line9_DebtsTo_Prd, 1456 | @Line10_DebtsBy_Prd, @Line11a1_Itemized_Prd, @Line11a2_Unitemized_Prd, @Line11a3_Total_Prd, 1457 | @Line11b_PolPtyComms_Prd, @Line11c_OtherPACs_Prd, @Line11d_TotalContribs_Prd, @Line12_TransfersFrom_Prd, 1458 | @Line13_AllLoansRcvd_Prd, @Line14_LoanRepymtsRecv_Prd, @Line15_OffsetsToOpExps_Refunds_Prd, 1459 | @Line16_RefundsOfFedContribs_Prd, @Line17_OtherFedRects_Divds_Prd, 1460 | @Line18a_TransfersFromNonFedAcct_H3_Prd, @Line18b_TransfersFromNonFed_LevinH5_Prd, 1461 | @Line18c_TotalNonFedTransfers_Prd, @Line19_TotalReceipts_Prd, @Line20_TotalFedReceipts_Prd, 1462 | @Line21a1_FedShare_Prd, @Line21a2_NonFedShare_Prd, @Line21b_OtherFedOpExps_Prd, @Line21c_TotOpExps_Prd, 1463 | @Line22_TransToOtherComms_Prd, @Line23_ContribsToFedCandsOrComms_Prd, @Line24_IndptExps_Prd, 1464 | @Line25_CoordtdExpByPrtyComms_Prd, @Line26_LoanRepayments_Prd, @Line27_LoansMade_Prd, 1465 | @Line28a_IndivRefunds_Prd, @Line28b_PolPartyCommRefunds_Prd, @Line28c_OtherPolCommRefunds_Prd, 1466 | @Line28d_TotalContRefunds_Prd, @Line29_OtherDisb_Prd, @Line30a1_SharedFedActH6FedShare_Prd, 1467 | @Line30a2_SharedFedActH6NonFed_Prd, @Line30b_NonAlloc100PctFedElecActivity_Prd, 1468 | @Line30c_TotFedElecActivity_Prd, @Line31_TotDisbmts_Prd, @Line32_TotFedDisbmts_Prd, 1469 | @Line33_TotContribs_Prd, @Line34_TotContribRefunds_Prd, @Line35_NetContribs_Prd, 1470 | @Line36_TotFedOpExps_Prd, @Line37_OffsetsToOpExps_Prd, @Line38_NetOpExps_Prd, 1471 | @Line6b_CashBegin_Tot, @Line6b_Year, @Line6c_TotalRects_Tot, @Line6d_CashBeginSubtotal_Tot, 1472 | @Line7_TotDisbmts_Tot, @Line8_CashOnHandAtClose_Tot, @Line11a1_Itemized_Tot, 1473 | @Line11a2_Unitemized_Tot, @Line11a3_Total_Tot, @Line11b_PolPtyComms_Tot, @Line11c_OtherPACs_Tot, 1474 | @Line11d_TotalContribs_Tot, @Line12_TransfersFrom_Tot, @Line13_AllLoansRcvd_Tot, 1475 | @Line14_LoanRepymtsRecv_Tot, @Line15_OffsetsToOpExps_Refunds_Tot, @Line16_RefundsOfFedContribs_Tot, 1476 | @Line17_OtherFedRects_Divds_Tot, @Line18a_TransfersFromNonFedAcct_H3_Tot, 1477 | @Line18b_TransfersFromNonFed_LevinH5_Tot, @Line18c_TotalNonFedTransfers_Tot, 1478 | @Line19_TotalReceipts_Tot, @Line20_TotalFedReceipts_Tot, @Line21a1_FedShare_Tot, 1479 | @Line21a2_NonFedShare_Tot, @Line21b_OtherFedOpExps_Tot, @Line21c_TotOpExps_Tot, 1480 | @Line22_TransToOtherComms_Tot, @Line23_ContribsToFedCandsOrComms_Tot, @Line24_IndptExps_Tot, 1481 | @Line25_CoordtdExpByPrtyComms_Tot, @Line26_LoanRepayments_Tot, @Line27_LoansMade_Tot, 1482 | @Line28a_IndivRefunds_Tot, @Line28b_PolPartyCommRefunds_Tot, @Line28c_OtherPolCommRefunds_Tot, 1483 | @Line28d_TotalContRefunds_Tot, @Line29_OtherDisb_Tot, @Line30a1_SharedFedActH6FedShare_Tot, 1484 | @Line30a2_SharedFedActH6NonFed_Tot, @Line30b_NonAlloc100PctFedElecActivity_Tot, 1485 | @Line30c_TotFedElecActivity_Tot, @Line31_TotDisbmts_Tot, @Line32_TotFedDisbmts_Tot, 1486 | @Line33_TotContribs_Tot, @Line34_TotContribRefunds_Tot, @Line35_NetContribs_Tot, 1487 | @Line36_TotFedOpExps_Tot, @Line37_OffsetsToOpExps_Tot, @Line38_NetOpExps_Tot); 1488 | 1489 | -- Return value to show new header row added. 1490 | SELECT 0; 1491 | RETURN 0; 1492 | 1493 | SET NOCOUNT OFF 1494 | GO 1495 | 1496 | 1497 | --------------------------------------------------------------------------------